dongqiuxu2270 2017-02-09 07:20
浏览 125

Yii2 Swiftmailer有时无法连接到SMTP,返回内部服务器错误

Sometimes my program can send a message and sometimes not, according to one of my colleagues it is because of the connectivity here in our place. Sometimes I can't ping the SMTP address.

Now I tried retrying to send the message in a loop, yet it doesn't because the program will stop because of an internal server error.

  $mail_params = $params['mail'];
  $transport = \Swift_SmtpTransport::newInstance($mail_params['smtp'], $mail_params['port'], $mail_params['encryption'])
  ->setUsername($mail_params['user'])
  ->setPassword($mail_params['password']);

  $mailer = \Swift_Mailer::newInstance($transport);
  $message = \Swift_Message::newInstance($subject)
               ->setFrom([Yii::$app->params['notificationEmail'] => 'TMC Scheduler'])
               ->setTo([$to])
               ->setBody(trim($email_message));

             while ($i = 0) {
                $i = $mailer->send($message);
             }

             return $i

I've been stuck here 4 days. Do you guys have any ideas? I'm running out of it.

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?