duanjiao5261 2015-04-21 14:05
浏览 43
已采纳

send方法总是返回0

I'm using swift_mailer to handle sending emails and I'm having a problem which is emails are not sent, and the return value of the send method is always equal to zero.

<kbd>app/config/config.yml</kbd>

swiftmailer:
   transport: smtp
   host:      <host>  # of the company
   username:  <username> # of the company
   password:  <password> # of the company
   port: 25

<kbd>app/config/config_test.yml</kbd>

swiftmailer:
    disable_delivery: true
    # disable_delivery: ~ # tried with this too

<kbd>Controller</kbd>

$mailer = $this->get('mailer');
$message = $mailer->createMessage()
    ->setSubject('You have Completed Registration!')
    ->setFrom('send@example.com')
    ->setTo('valid_email@Iswear.fr')
    ->setBody(
        'hello world!!',
        'text/plain'
    )

var_dump($mailer->send($message, $failed), $failed); exit;

Output:

int(0)
array(0) {
}

I know that send returns the number of persons the email has been sent to. Why the email is never sent? Given that I'm sure of the only email address I'm trying to send to.

Update1:

I'd like to know how to debug this much further.

  • 写回答

2条回答 默认 最新

  • duannian3494 2015-04-21 14:12
    关注

    If you want to achieve a test environment mailer, do not use disable_delivery.
    That completely disables swiftmailer's send.
    Use

    # app/config/config_dev.yml
    swiftmailer:
          disable_delivery: false
          delivery_address: dev@example.com # some test or development email account
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!