15

I am getting this error Expected response code 250 but got code "550", with message "550 5.7.1 Relaying denied " when I try using mailgun and laravel 7 to send emails. But I do not know what to do

Tula
  • 189
  • 1
  • 1
  • 7

2 Answers2

40

Make sure you have MAIL_MAILER=mailgun instead of MAIL_DRIVER=mailgun

It changed in Laravel 7+.

Use something like this:

MAIL_FROM_ADDRESS=no-reply@example.com
MAIL_FROM_NAME=example
MAIL_MAILER=mailgun
MAILGUN_DOMAIN=mailgun-domain.example
MAILGUN_SECRET=example-key-here
MAILGUN_ENDPOINT=api.mailgun.net
MAIL_ENCRYPTION=tls
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Abeer Sul
  • 944
  • 9
  • 22
3

Check your config/mail.php file, to see whether MAIL_DRIVER or MAIL_MAILER is an env value. Then set MAIL_DRIVER or MAIL_MAILER in the .env file.

By default, emails are sent via SMTP. If you have set, for instance, MAILGUN_DOMAIN and MAILGUN_SECRET, expecting to us the API, this will not be the case, if the MAIL_DRIVE/MAIL_MAILER is not set up mailgun.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Darren Murphy
  • 1,076
  • 14
  • 12