我从Gmail帐户向自己发送了错误电子邮件,并且该邮件正在运行。
突然,电子邮件崩溃了,我得到了
Swift_TransportException:预期的响应代码为250,但代码为“”,并显示消息“”。
我不确定为什么会发生这种情况,因此我发送了大约80封电子邮件。
这是我的代码:
$backup = Mail::getSwiftMailer();
// Setup your gmail mailer
$transport = \Swift_SmtpTransport::newInstance($email_config['host'], $email_config['port'], $email_config['security']);
$transport->setUsername($email_config['from_email']);
$transport->setPassword($email_config['from_email_password']);
// Any other mailer configuration stuff needed...
$gmail = new \Swift_Mailer($transport);
// Set the mailer as gmail
Mail::setSwiftMailer($gmail);
$cc = $email_config["cc"];
$to_email = $email_config["to"];
\Log::info("mail 1");
\Log::info($to_email);
// Send your message
\Mail::send('emails.error_log', ['body' => $body], function ($message) use ($from_email, $to_email, $subject, $cc) {
$message->from($from_email);
$message->to($to_email);
$message->cc($cc);
$message->subject($subject);
});
\Log::info("mail 2");
// Restore your original mailer
Mail::setSwiftMailer($backup);