php – Symfony SwiftMailer – 预期的响应代码220但是得到了代
发布时间:2020-12-13 22:25:30 所属栏目:PHP教程 来源:网络整理
导读:我知道这个问题在SO上有很多像 this这样的答案,但是没有一个解决方案对我有用. 我正在尝试从我的Google Apps域发送电子邮件.大多数时间都会发送电子邮件,但有时会抛出此异常并且不会发送电子邮件. Uncaught PHP Exception Swift_TransportException: "Expect
我知道这个问题在SO上有很多像
this这样的答案,但是没有一个解决方案对我有用.
我正在尝试从我的Google Apps域发送电子邮件.大多数时间都会发送电子邮件,但有时会抛出此异常并且不会发送电子邮件. Uncaught PHP Exception Swift_TransportException: "Expected response code 220 but got code "",with message """ at C:HostingSpacesabcdomain.comwwwrootvendorswiftmailerswiftmailerlibclassesSwiftTransportAbstractSmtpTransport.php line 383 {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 220 but got code "",with message "" at C:HostingSpacesabcdomain.comwwwrootvendorswiftmailerswiftmailerlibclassesSwiftTransportAbstractSmtpTransport.php:383)"} [] 是的,我使用SSL,是的,我已经允许访问不太安全的应用程序,是的我使用端口465.我已启用假脱机,以便应用程序不会崩溃,因为异常不会被捕获. 我的config.yml如下 swiftmailer: transport: smtp host: smtp.gmail.com username: no-reply@googledomain.com password: password port: 465 encryption: ssl spool: { type: memory } 我的电子邮件课程如下 public function send_new_order_email($entity) { try{ $message = $this->getEmailObj("toaddress@gmail.com"); $message->setBody( $this->renderView( 'APIBundle:Emails:ops_neworder.html.twig',array('entity' => $entity) ),'text/html' )->setSubject('New Order : '.$entity->getId()); $this->container->get('mailer')->send($message); } catch(Exception $e){} } private function getEmailObj($email){ $message = Swift_Message::newInstance() ->setFrom('no-reply@googledomain.com') ->setTo($email); return $message; } 你对这项工作有什么建议吗? 解决方法
在Symfony中,Swiftmailer是一个专门用于Gmail的配置,它处理电子邮件通信而忘记了其余的配置.这项工作对我来说很多次:
swiftmailer: transport: gmail username: your_gmail_username password: your_gmail_password 我希望这对你有意义 You have more information here (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |