TPDev
1998
5
Laravel

Laravel sending mail via mailtrap not working with no errors

Posted 1 year ago by TPDev

Attempting to send some dev testing emails from a Laravel Application. Followed this guide here: https://www.youtube.com/watch?v=zu-ZniGhogw

made a mailtrap.io account inbox, copied all its details to .env Everything works as in the video, however no email is sent or received in the mailbox Also when trying to log the email instead nothing is happening. No errors, nowhere.

app\mail\NewUserWelcome.php

public function build()
{
    return $this->markdown('emails.newuserwelcome');
}

Controller method:

public function email()
{
    Mail::to(Auth::user()->email)->send(new NewUserWelcome());
    return redirect ('/home');
}

resources\views\emails\newuserwelcome.blade.php

@component('mail::message')

Welcome to Application Name

Thanks for signing up. **We really appreciate** it. Let us _know if we can_ do more to please you!

@component('mail::button', ['url' => 'http://localhost:8000/home']) View My HomePage @endcomponent

Thanks, {{ config('app.name') }} @endcomponent

This is my app\config\mail.php

'driver' => env('MAIL_DRIVER', 'smtp'), host' => env('MAIL_HOST', 'smtp.mailtrap.io'), 'port' => env('MAIL_PORT', 2525), 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', '[email protected]'), 'name' => env('MAIL_FROM_NAME', 'Example'), ], 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'sendmail' => '/usr/sbin/sendmail -bs', 'markdown' => [ 'theme' => 'default',

    'paths' => [
        resource_path('views/vendor/mail'),
    ],
],

"pretend" => false

This is my .env:

MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=xxxxxxxxxxxxxxxxx MAIL_PASSWORD=xxxxxxxxxxxxxxxxx MAIL_ENCRYPTION=tls [email protected] MAIL_FROM_NAME=Example

I've tested this locally on a WAMP server And Remotely on Ubunto LAMP server same results (I.E nothing happening)

-Thanks for any help you can provide

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