我正在尝试使用PHPMailer发送电子邮件,但我无法发送。实际上,我正在研究其他高级开发人员已经建立的现有系统。 这就是我的尝试:
$mail = new PHPMailer(true);
try {
$mail->isSMTP(); // Set mailer to use SMTP
$mail->isHTML(true);
$mail->addAddress("rmali@growbydata.com");
$mail->addAddress("pshrestha@growbydata.com");
$mail->addAddress($userEmail);
$mail->Host = $f3->get('GBD.smtp.host'); // Specify main and backup SMTP servers
$mail->From = $user['email'];
$userFullName = trim(ucfirst($user['firstname'])) . " " . trim(ucfirst($user['lastname']));
$mail->FromName = $userFullName;
$mail->Body = "<br><br>".$f3->get('message');
$mail->Body .="<br>". $mailBody;
$mail->AltBody = 'Employee has requested for assistance. Please comply.
Issued Date:' . $f3->get('issuedDate') . '<br>Issued Selection:' . $f3->get('issueSelection') . '<br>Issue Priority:' . $f3->get('issuePriority') . '<br>Issue Description:' . $f3->get('issueDescription');
$mail->Subject = 'Updates on issue report';
$mailStatus = (boolean)$mail->send();
if ($mailStatus === true) {
return $mail; //object is being sent here.. anyone know this?
}
} catch (phpmailerException $e) {
$response = array(
'status'=>'error',
'message'=>'Got some error while sending emails',
'exceptions'=>$e->getMessage()
);
return $response;
}
}
以下是我尝试从控制器发送邮件的方式:
$emailStatus = EmailHelper::issueMail(); //send email
if($emailStatus==TRUE){
echo 'this works though';
exit;
}
$ mail正在发送PHPMailer实例而不是boolean&#39; emailStatus&#39;但似乎工作正常,我不知道为什么。但我没有收到任何电子邮件。我在config.ini文件中的SMTP配置如下:
GBD.smtp.host = smtp.wlink.com.np
; Will receive all exported logs as an email
;GBD.smtp.exportemail = "trourk@growbydata.com"
GBD.smtp.email[0] = "malakar.rakesh1993@gmail.com"
;GBD.smtp.email[1] = "pramitshrest@gmail.com"
GBD.smtp.password = ""
GBD.smtp.from = "noreply@growbydata.com"
GBD.smtp.fromName = "NoReply GrowByData"
GBD.smtp.subject = "Leave Request Application"
GBD.smtp.email_template = ""
我检查了一切,但没有运气。请帮帮我。