Lavarel 5.2-邮件随机出现异常超时

时间:2019-05-06 07:23:19

标签: php email laravel-5.2

我正在使用PHP 5.6和Laravel 5.2

我的电子邮件在cron队列中运行。但是随机得到了异常超时。

与tcp://mail.example.com的连接:587超时

这是我的代码:

    public function sendNotificationByEMail($information){
        Mail::send($information['template'], ['param' => $information['param']], function ($message) use ($information) {
            $message->from('admin@example.com', $information['mailAlias']);
            $message->to($information['mail']);
            if(isset($information['cc']) && !empty($information['cc'])){
                $message->cc($information['cc']);
            }
            $message->subject($information['subject']);
        });
    }
class SendNotificationEmail extends Job implements ShouldQueue
use InteractsWithQueue, SerializesModels;


try {
     $modelHelper->sendNotificationByEMail($result);
} catch(Exception $ex) {
     $param['push_notification_note'] = $ex->getMessage();
}

这是我的邮件配置:

 'driver' => env('MAIL_DRIVER', 'smtp'),
 'host' => env('MAIL_HOST', 'mail.example.com'),
 'port' => env('MAIL_PORT', 587),
 'from' => ['address' => env('MAIL_FROM'), 'name' => env('MAIL_NAME')],
 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
 'username' => env('MAIL_USERNAME'),
 'password' => env('MAIL_PASSWORD'),
 'sendmail' => '/usr/sbin/sendmail -bs',

我的代码是错误的,还是服务器有问题?

0 个答案:

没有答案