uccdev
4 months ago
834
11
Laravel

Laravel: email is sent, but not received?

Posted 4 months ago by uccdev

So I have this function to send an email:

         public function email($data) {
               Mail::raw("Simple email to confirm email functionality works", function($message) {
                 $message->to('[email protected]');
                 $message->from('[email protected]');
               });
               if (count(Mail::failures()) > 0) {
                 Log::info("Error! Email did not send.");
               }
               Log::info("email sent");
         }

    .....
    self::email($data);
    ....

My config/mail.php is configured like so:

    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'port' => env('MAIL_PORT', xxx),
    'from' => [
            'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
            'name' => env('MAIL_FROM_NAME', 'me'),
    ],
            ....

So I expect my mailtrap account, when the function is called, to send an email to the designated "[email protected]". And it does, it sends an email: I can see that clearly from the logs on my mailtrap account.

But, [email protected] receives nothing. Not in my inbox, and not in my junk email.

Any advice on what could be going on here? Any help would be appreciated

Please sign in or create an account to participate in this conversation.