我想使用Mandrill發送我的電子郵件。我正在自定義我的phpmailer,我曾經用mandrill phpmailer發送郵件。 (這裏找到:http://help.mandrill.com/entries/23737696-How-do-I-send-with-PHPMailer-)使用Mandrill發送郵件PHPmailer無法使用
require 'mandrillmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'MANDRILL_USERNAME'; // SMTP username
$mail->Password = 'MANDRILL_APIKEY'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = '[email protected]';
$mail->FromName = 'Your From name';
$mail->AddAddress($to); // Add a recipient
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $message;
echo $mail->Subject;
//$mail->Send();
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'hiii';
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
else{
echo 'hello';
echo 'Message has been sent';
}
die('here');
我沒有得到即郵件發送或不響應消息。我通過echo語句調試了它被卡住的地方。我可以看到直到echo $mail->Subject;
的消息,但沒有超出。我猜$mail->Send()
不能正常工作,這就是爲什麼超出這個範圍的信息沒有顯示和電子郵件發送不起作用。
我該如何解決這個問題?
什麼是'$ MAIL-> ErrorInfo'返回? – Grokify 2015-03-31 12:04:20
@Grokify:我不能說。在代碼中,上面提供的鏈接來自官方網站。我想這是爲了顯示錯誤信息。 – kiran 2015-03-31 12:07:10