Laravel Error : All RCPT commands were rejected with this error 503

Laravel Error : All RCPT commands were rejected with this error 503

Laravel implements a wrapper on top of the SwiftMailer library that makes email management very easy to configure and use at the same time. 

The “Error 503: Valid RCPT command must precede DATA” happens when sending email. It’s telling you that your SMTP (outgoing mail) connection was not properly authenticated by your email server.

The three most common causes of this error are:

  1. Your email server requires you to check email first before sending email. (Checking email first is one way your email provider manages the security of your email account.)
  2. Some email provider also check the sender address also, if sender email address doesn't exist then you will get a 503 error.
  3. Your email client isn’t set up for SMTP Authentication.

More often, Error 503 tells you that you need to set up SMTP Authentication in your email client.

In Laravel you can catch this error and can show an error message like this,

try {
  Mail::send('emails.contact-message', [
   'msg' => $request->body,
   'name' => $request->name,
   'email' => $request->email,

  ],

     function ($mail) use($request) {
       $mail->from($request->email, $request->name);
       $mail->to('[email protected]')->subject('Contact Message');
     }
   );
 // Catch the error
 } catch(\Swift_TransportException $e){
    if($e->getMessage()) {
       dd($e->getMessage());
    }             
 }

By default, Laravel authencation uses [email protected] to send forget password email. If your SMTP provider check sender mail address too, then you will get 503 error. So you also need to change MAIL_FROM_ADDRESS & MAIL_FROM_NAME from the config/mail.php like this :

'from' => [
     'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
     'name' => env('MAIL_FROM_NAME', 'System'),
 ],

Alternatively you can add this two lines on .env like this,

[email protected]
MAIL_FROM_NAME=System

Hope this post help you.


Except where otherwise noted, content on this site is licensed under a CC BY-NC-SA 4.0 .