无法发送电子邮件将SwiftMailer与Mandrill一起抛出


Can not send email threw SwiftMailer with Mandrill

从今天起,我的许多php应用程序无法使用SwiftMailer和不同的Mandrill帐户发送电子邮件。

我有这段代码,最后一个if中的send函数停止了脚本。。

// Instance message
$message = Swift_Message::newInstance();
$message->setSubject("subject")
        ->setFrom(array('noreply@email.test' => 'test'))
        ->setTo(array('a_valid_email' => 'name'))
        ->setBody("test", 'text/html')
        ->setPriority(2);
$smtp_host     = 'smtp.mandrillapp.com';
$smtp_port     = 587;
$smtp_username = 'valid_username';
$smtp_password = 'valid_password';
// SMTP
$smtp_param = Swift_SmtpTransport::newInstance($smtp_host , $smtp_port)
        ->setUsername($smtp_username)
        ->setPassword($smtp_password);
// Instance Swiftmailer
$instance_swiftmailer = Swift_Mailer::newInstance($smtp_param);
$type = $message->getHeaders()->get('Content-Type');
$type->setValue('text/html');
$type->setParameter('charset', 'iso-8859-1');
//Here the send function stop event and I did not go inside the if      
    if ($instance_swiftmailer->send($message, $fail)) {
        echo 'OK ';
    }else{
        echo 'NOT OK : ';
        print_r($fail);
    }

提前谢谢你帮我解决这个问题。。

如果您的代码过去可以工作,现在不工作了,并且您没有更改代码,那么这可能不是代码的问题。检查您的Mandrill帐户的有效性-有时他们会因可疑的使用情况而暂停帐户。