簡體   English   中英

電子郵件未通過Swift Mailer Symfony2接收

[英]Email is not Receiving through Swift Mailer Symfony2

  • 我試圖通過swiftmailer發送電子郵件

  • 響應代碼200正常,但仍未收到電子郵件。

控制器代碼

 public function EmaiAction(Request $request)
 {
    $mailer = $this->get('mailer');

    $logger = new \Swift_Plugins_Loggers_ArrayLogger();
    $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));


    $message = \Swift_Message::newInstance()
    ->setSubject('Hello')
    ->setFrom('mohd@abc.com')
    ->setTo('***@gmail.com')
    ->setBody('This is a test email.');

    if ($this->get('mailer')->send($message)) {
    echo '[SWIFTMAILER] sent email to ';
    } else {
    echo '[SWIFTMAILER] not sending email: ' . $mailer->dump();
    }    

die("email send");

}

產量

   [SWIFTMAILER] sent email to

config.yml

swiftmailer:
disable_delivery:  true
transport: smtp
encryption: ssl
port:   465
auth_mode: login
host:      smtp.gmail.com
username:  ***@gmail.com
password:  passwrd
delivery_address: abc@gmail.com
  • 在if / else中執行回顯,如果它進入if條件,則表示其為true。

  • 所以為什么我不接收電子郵件。

  • 發送電子郵件時沒有錯誤日志出現

  • 我正在使用cpanel應用程序是生產環境。

disable_delivery:  true

這將禁用郵件發送以進行開發(請參閱Docs

另外嘗試這樣的swiftmailer配置

swiftmailer:
    transport: gmail
    username:  ***@gmail.com
    password:  passwrd
$message = \Swift_Message::newInstance()
->setSubject('Hello')
->setFrom('mohd@abc.com')
->setTo('***@gmail.com')
->setBody('This is a test email.');
$this->get('mailer')->send($message);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM