PHPMailer SMTP连接失败

PHPMailer SMTP连接失败,php,email,mandrill,Php,Email,Mandrill,我试图通过Mandrill发送电子邮件,但没有成功(在本地主机上测试)。 有人能告诉我哪里出了问题吗 这是来自PHPMailer的详细信息: 2014-04-27 17:51:06 SERVER -> CLIENT: 220 smtp.mandrillapp.com ESMTP 2014-04-27 17:51:06 CLIENT -> SERVER: EHLO 127.0.0.1 2014-04-27 17:51:06 SERVER -> CLIENT: 250-ip-10-

我试图通过Mandrill发送电子邮件,但没有成功(在本地主机上测试)。
有人能告诉我哪里出了问题吗

这是来自PHPMailer的详细信息:

2014-04-27 17:51:06 SERVER -> CLIENT: 220 smtp.mandrillapp.com ESMTP
2014-04-27 17:51:06 CLIENT -> SERVER: EHLO 127.0.0.1
2014-04-27 17:51:06 SERVER -> CLIENT: 250-ip-10-107-129-238
                                      250-PIPELINING
                                      250-SIZE 26214400
                                      250-STARTTLS
                                      250-AUTH PLAIN LOGIN
                                      250-ENHANCEDSTATUSCODES
                                      250 8BITMIME
2014-04-27 17:51:06 CLIENT -> SERVER: STARTTLS
2014-04-27 17:51:06 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2014-04-27 17:51:06 CLIENT -> SERVER: QUIT
2014-04-27 17:51:16 SERVER -> CLIENT:
2014-04-27 17:51:16 SMTP ERROR: QUIT command failed: SMTP connect() failed. Message could not be sent.
Mailer Error: SMTP connect() failed.
这是我的密码:

$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 = 'example@mail.com';                 // yes, I have entered my username mail
        $mail->Password = 'xxxxxxxxxxxx-xxxxxxxxx';           // yes, API key is here
        $mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted
        $mail->From = 'from@example.com';
        $mail->FromName = 'Your From name';
        if($test_mode) {
            $mail->SMTPDebug = 2;
            $mail->AddAddress('mymail@gmail.com');
        } else {
            $mail->AddAddress($email);
        }
        $mail->IsHTML(true);                                  // Set email format to HTML
        $mail->WordWrap = 70;                                 // Set word wrap to 70 characters
        //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments

        $mail->Subject = '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()) {
            //redirect to
            echo 'Message could not be sent.<br>';
            echo 'Mailer Error: ' . $mail->ErrorInfo;
            exit;
        }

它会起作用的!但是现在加密被禁用了。为什么在启用加密的情况下不工作?

取消php\u openssl.dll在php.ini中的注释时区设置是否正确

在加载phpmailer之前包含时区定义

date_default_timezone_set('Etc/UTC');

require '../PHPMailerAutoload.php';

$mail = new PHPMailer();

另外,如果你在gmail域名上试用,它可能已经被屏蔽了。检查地址:

是,当您删除
$mail->SMTPSecure='tls'时这是因为未加载
php\u openssl.dll
date_default_timezone_set('Etc/UTC');

require '../PHPMailerAutoload.php';

$mail = new PHPMailer();