當我嘗試使用此PHPMailer方法使用mandrill發送郵件時,它顯示爲SMTP Connect()失敗的錯誤。這是我的代碼:Mandrill PHPMailer給出錯誤:SMTP連接()失敗
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = 'smtp.mandrillapp.com';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'MANDRILL_USERNAME';
$mail->Password = 'API_KEY';
$mail->From = '[email protected]';
$mail->FromName = 'Your From name';
$mail->AddAddress('[email protected]');
$mail->IsHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
?>
我無法找到問題。我還包含了從中獲取class.phpmailer.php文件的phpmailer文件。請幫助...