Laravel mail sending through smtp server error 503 5.5.2

This is the .env config file:

    MAIL_DRIVER=smtp
    MAIL_HOST= smtp.server.address
    MAIL_PORT=25  
    MAIL_USERNAME=Your smtp username (if exists)
    MAIL_PASSWORD=Your smtp password (if exists)
    MAIL_ENCRYPTION=ssl
    MAIL_FROM_ADDRESS=your email smtp address
    MAIL_FROM_NAME=your name 

But you should check the correctly params of your smpt server. I can help you if you want.


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());
    }             
 }

i had the same issue long time but i have fixed it

While you are in the local serve ie) xampp or wampp etc

MAIL_DRIVER=smtp


MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

but when you are going in live server

MAIL_DRIVER=sendmail


MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

Just Change the mail driver to sendmail I have no idea how its is working but it fixed my server-error-503


If you send a mail from a hostname same as the EMAIL_USERNAME in you .env and the mail doesn't exist in your host server. You get that error. i.e

If EMAIL_USERNAME: [email protected] then mail_from is something like this ->from('[email protected]') and [email protected] doesn't exist.

In Summary

To send emails from a mail address like "[email protected]" or any mail at all; it is important that you have created that mail on your server or cpanel else it throws the error: "503-All RCPT commands were rejected with this error: 503-Sender verify failed 503 Valid RCPT command must precede DATA"

Tags:

Php

Email

Laravel