Laravel's Mail notification won't send, but Laravel's Mail::Raw will

▼魔方 西西 提交于 2020-01-05 04:56:11

问题


I have configured my SMTP server correctly in Laravel's env file, and can successfully send an email using Mail::raw e.g.

Mail::raw("This is a test message", function ($message) 
{ 
    $message->from(env("MAIL_ORDER_ADDRESS"), 'Orders'); 
    $message->to('user@example.com'); 
    $message->subject('Test Message'); 
});

However, when I use a laravel 5.3 mail notification, no email is received (nor is an error generated). I have tested the same notification code locally using mail trap and the notifications work correctly.

I can't understand how if the mail server is working and can be used with Mail::raw, it doesn't automatically work with notifications when I have tested locally and confirm they are coded correctly.

Note: Using shared hosting on NameCheap.

Any ideas?


回答1:


FIXED: It was because I had not configured "From" in config/mail.php and because the domains didn't match, it wasn't set.




回答2:


The opposite situation is occurring for me. I have the MAIL_DRIVER=mail set within the .env file.

I have set MAIL_FROM_ADDRESS & MAIL_FROM_NAME within the .env file and viewed the app/config/mail.php

Mail::raw is sending out email correctly via the Postfix logs but any emails sent via the new Laravel 5.3 Notifications is not working. No errors or any information writing to the logs.

There appears to be some other issue occurring.




回答3:


I had the same issue. During testing for Mail::raw, i had set MAIL_ENCRYPTION to empty. When I set MAIL_ENCRYPTION=tls for notify email, it started working.



来源:https://stackoverflow.com/questions/40423677/laravels-mail-notification-wont-send-but-laravels-mailraw-will

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!