How to close Smtp connection in SwiftMailer

前端 未结 5 1277
借酒劲吻你
借酒劲吻你 2020-12-31 04:37

I use SwiftMailer to send emails from a gearman worker process. I\'m using the Swift_SmtpTransport class to send emails.

The problem is that if this wor

5条回答
  •  别那么骄傲
    2020-12-31 05:24

    I'm running a worker in an infinite loop using Swiftmailer and AWS SES I was getting the error:

    Expected response code 250 but got code "421", with message "421 Timeout waiting for data from client.
    

    Solution for my script:

    $love = true;
    while($love) {
        $message = Message::to($record->to)
            ->from(array('no-reply@clouddueling.com' => $user->name()))
            ->reply(array($user->email => $user->name()))
            ->subject($record->subject)
            ->body($body->value)
            ->html(true)
            ->send();
    
        if (! $message->was_sent())
            throw new Swift_TransportException($errstr . ': ' . $errno);
    }
    

提交回复
热议问题