2
votes

I am trying to set up mail sending with mailgun on my deployed laravel application. I am able to send email verification emails, but I can't send to my email. For example:

Notification::route('mail', 'admin@mywebsite.org')
        ->notify(new Feedback($user->email, $subject, $message));

When I was using mailtrap.io to test my mail sending it worked perfectly.

My .env file looks like this:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAILGUN_SECRET=key-<key>
MAIL_USERNAME=postmaster@sandbox<somenums>.mailgun.org
MAIL_PASSWORD=<mypass>
MAIL_ENCRYPTION=tls

When I try to send the email it brings this error: Expected response code 250 but got code "554", with message "554 Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings. "

1

1 Answers

0
votes

welcome to SO.

Please have a deeper look at the Laravel official documentation where you can find everything you need to set up the mailgun driver.

Mailgun Driver To use the Mailgun driver, first install Guzzle, then set the driver option in your config/mail.php configuration file to mailgun. Next, verify that your config/services.php configuration file contains the following options:

'mailgun' => [
  'domain' => 'your-mailgun-domain',
  'secret' => 'your-mailgun-key',
],

After updating your conf you have to change the MAIL_DRIVER env variable from smtp to mailgun. All the other settings for username, password and so on are not required.