Mandrill错误:无法与主机smtp.mandrillapp.com建立连接

时间:2014-12-24 11:55:04

标签: mandrill

我不是想做任何花哨的事情。我只是想用mandrill的API发送电子邮件。我已经包含了库但我仍然收到错误:"致命错误:未捕获的异常' Swift_TransportException'消息'无法与主机smtp.mandrillapp.com建立连接[连接拒绝#111]'在/home/laundryanna/public_html/mandrill/lib/classes/Swift/Transport/StreamBuffer.php:265堆栈追踪:#0 /home/laundryanna/public_html/mandrill/lib/classes/Swift/Transport/StreamBuffer.php(62 ):Swift_Transport_StreamBuffer-> _establishSocketConnection()#1 /home/laundryanna/public_html/mandrill/lib/classes/Swift/Transport/AbstractSmtpTransport.php(113):Swift_Transport_StreamBuffer-> initialize(Array)#2 / home / laundryanna / public_html / mandrill / lib / classes / Swift / Mailer.php(79):Swift_Transport_AbstractSmtpTransport-> start()#3 /home/laundryanna/public_html/mandrill/mailed.php(26):Swift_Mailer-> send(Object( Swift_Message),Array)在第265行" /home/laundryanna/public_html/mandrill/lib/classes/Swift/Transport/StreamBuffer.php中抛出#4 {main}。这是代码:

<?php

include_once "lib/swift_required.php";

$subject = 'Hello from Mandrill, PHP!';
$from = array('mail1@example.com' =>'EA CEO');
$to = array(
 'email1@gmail.com'  => '$_POST["e1"]',
 'email1' => 'Recipient2 Name'
);

$text = "Mandrill speaks plaintext";
$html = "<em>Mandrill speaks <strong>HTML</strong></em>";

$transport = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587);
$transport->setUsername('***ore@gmail.com');
$transport->setPassword('******');
$swift = Swift_Mailer::newInstance($transport);

$message = new Swift_Message($subject);
$message->setFrom($from);
$message->setBody($html, 'text/html');
$message->setTo($to);
$message->addPart($text, 'text/plain');

if ($recipients = $swift->send($message, $failures))
{
 echo 'Message successfully sent!';
} else {
 echo "There was an error:\n";
 print_r($failures);
}

?>

请告诉我该怎么做...... :(

0 个答案:

没有答案