Monday 13 January 2020

Laravel + Swift Mailer: Error: no valid recipients

I tried to set up a connection to my mailserver with Laravel/Swiftmailer. The Mailing section of my .env looks as follows:

MAIL_DRIVER=smtp
MAIL_HOST=<THE MAILHOST>
MAIL_PORT=465
MAIL_USERNAME=<THE USERNAME>
MAIL_PASSWORD=<THE PASSWORD>
MAIL_ENCRYPTION=ssl

Personal information is censored for obvious reasons, but the configuration does work. I tested it by connecting to the server with this configuration with thunderbird and it works like a charm.

Here is where I call the Mailable:

   public function from_id(string $id): User
   {
         .
         .
         .
        Mail::to(<WORKING EMAIL ADRESS>)->send(new OrderShipped());
    }

Thats how the Mailable looks like (it basically is the example one from the laravel docs):

   public function build()
   {
      return $this->view('email_templates.simple_test');
   }

I debugged into the code and there are actually two exceptions thrown, altough whoops! only shows the latter:

Expected response code 250/251/252 but got code "554", with message "554 5.7.1 : Recipient address rejected: Access denied"

Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients"

I tried to sent an email from the perfectly working mailserver via thunderbird to the <WORKING EMAIL ADRESS> and the mail got sent and received in a fraction of a second and without any problems/errors. Basically, I tried to reproduce the exact same scenario with a different tool. So from my point of view, the error must be in the codebase.

Thanks in advance



from Laravel + Swift Mailer: Error: no valid recipients

No comments:

Post a Comment