Search code examples
laravellaravel-5smtplaravel-5.3laravel-mail

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


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('[email protected]'); 
    $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?


Solution

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