SMTP错误:无法连接到服务器:连接超时(110)

时间:2015-05-20 06:34:14

标签: php email mandrill

Connection: opening to smtp.mandrillapp.com:587, timeout=300, options=array ()
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
Message could not be sent.Mailer Error: SMTP connect() failed.

我使用mandrillAPI发送电子邮件。它适用于我的localhost。我可以从我的localhost发送邮件。但是当我在测试服务器上使用它时,它没有连接到mandrill服务器。它显示了上述错误。我检查了端口,它是打开的。我可以从我的服务器上使用gmail smtp。它工作正常。但我需要使用mandrillAPI。我还在域名上添加了DKIM和SPF记录。但仍然没有连接到smtp.mandrillapi.com 这是我使用的代码。

<?php
require 'PHPMailerAutoload.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->SMTPDebug = 4;
$mail->Debugoutput='html';
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'example@gmail.com';                // SMTP username
$mail->Password = 'apikey';                  // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted

$mail->From = 'example@gmail.com';
$mail->FromName = 'example';
$mail->AddAddress('example@gmail.com', 'Nidheesh');  // Add a recipient
         // Name is optional
$mail->addReplyTo('example@gmail.com');

$mail->IsHTML(true);                                  // Set email format to HTML

$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';
?>

`

0 个答案:

没有答案