Home  >  Q&A  >  body text

Laravel 9: Expected response code "250/251/252" but received error message "550 5.7.1 Relaying denied" with code "550"

Trying to send an email using mailtrap... I successfully implemented it on localhost and it works fine, but after deploying to heroku I can't get it to work on the live server. What is the solution?

This is the smtp settings in my .env file

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=31239f96d871e7
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="browynlouis2@gmail.com"
MAIL_FROM_NAME="${APP_NAME}"

This is exactlywhat it looks like in my heroku

P粉752812853P粉752812853378 days ago871

reply all(1)I'll reply

  • P粉293341969

    P粉2933419692023-10-31 00:31:39

    For live servers such as hosting servers, change the .env settings for smtp

    ................................................................. ......................................................................... ........................................

    Mail_Mailer=smtp

    Mail_Host=smtp.hostinger.com

    Mail_Port=465

    Mail_Username=example@domain.com

    Mail_Password=Password

    Mail_cryption=ssl

    Mail_From_Address=example@domain.com

    MAIL_FROM_NAME="${APP_NAME}"

    Then go to config/mail.phpChange the transport method smtp to mail

    'mailers' => [
    
        'smtp' => [
    
            'transport' => 'mail',      //before it was smtp
    
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    
            'port' => env('MAIL_PORT', 587),
    
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    
            'username' => env('MAIL_USERNAME'),
    
            'password' => env('MAIL_PASSWORD'),
    
            'timeout' => null,
    
            'local_domain' => env('MAIL_EHLO_DOMAIN'),
    
        ],

    reply
    0
  • Cancelreply