Hubert1957
Hubert1957

Reputation: 241

Laravel: cannot send notification to logged in user

I run into an issue with Laravel trying to send a notification to the logged in user.

I am running Laravel on top of Xampp.

My .env is set up like this:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=e577b5a0ea59d
MAIL_PASSWORD=320325e4b66352
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

I have sent out mails to Mailtrap (to a fictitious email) and that works well.

Now I am trying to send a notification to the logged in user:

public function store() {
    Notification::send(request()->user(), new PaymentRecieved());
}

I get an error message:

Swift_TransportException
Cannot send message without a sender address
http://localhost/L6/public/payments 

I am using the login methods that is included with Laravel/ui. My route looks like this:

Route::post('payments', "PaymentsController@store")->middleware('auth');

The authentication controllers I use are the one which are included with Laravel/ui.

I am getting the same error message when I am trying to use the reset password function.

I already tried all the advises about caches etc that I found, but none solves the problem.

Can anyone help?

Hubert

Upvotes: 0

Views: 93

Answers (2)

OMR
OMR

Reputation: 12218

Make sure you have set the 'from' in app/config/mail.php

'from' => ['address' => '[email protected]', 'name' => 'myname']

and then

php artisan config:cache

Upvotes: 0

user13132197
user13132197

Reputation:

You need to fill in the MAIL_FROM_ADDRESS and MAIL_FROM_NAME in your .env file, remember to clear cache via php artisan cache:clear afterwards.

Upvotes: 1

Related Questions