【问题标题】:Can not send email threw SwiftMailer with Mandrill无法用 Mandrill 发送电子邮件扔 SwiftMailer
【发布时间】:2015-04-11 00:52:03
【问题描述】:

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

我有这段代码,如果停止脚本,最后的发送函数..

// 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);
    }

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

【问题讨论】:

  • 运行代码时遇到的实际错误是什么?失败信息是什么?

标签: php swiftmailer mandrill


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 2015-02-12
    • 1970-01-01
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多