因此,我正在尝试设置swift mailer来使用Mandrill API,但它一直抛出以下错误:
失败:数组( => 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);
}哪里出了问题?
发布于 2012-08-10 09:57:47
尝试使用SSL和端口465。
$xport = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 465, 'ssl');
$xport->setUsername('mandrilluser')
->setPassword('mandrillpass');看看这对你是否有效。
发布于 2012-08-10 22:13:56
我的问题最终是,我必须从使用实际的Mandrill帐户密码更改为->setPassword()变量中的API。
发布于 2013-06-19 02:57:01
由于这纯粹是凭据的错误,请交叉检查您使用的密码是否实际上是由Mandrill生成的令牌。
Password不是指您帐户的“密码”!!
https://stackoverflow.com/questions/11893995
复制相似问题