所以我正在尝试设置 swift mailer 以使用 Mandrill API,但它不断抛出以下错误:
Failures:Array ( [0] => example@email.com ) (我的代码中的这个地方有一个正确的电子邮件)
我的代码如下:
$subject = 'Hello from Mandrill, PHP!';
// approved domains only!
$from = array('example2@email.com' =>'Your Name');
$to = array(
'example@email.com' => 'Recipient1 Name'
);
$text = "Mandrill speaks plaintext";
$html = "Mandrill speaks HTML";
$transport = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587);
$transport->setUsername(getenv('my@mandrillemail.com'));
$transport->setPassword(getenv('mymandrillpass'));
$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');
// Pass a variable name to the send() method
if (!$swift->send($message, $failures))
{
echo "Failures:";
print_r($failures);
}
出了什么问题?