Laravel SMTP sending email by queue receiving empty response - laravel

I'm running Laravel 6.20.0 and I'm experiencing the following error since yesterday when my queue worker is trying to send an email:
Swift_TransportException: Expected response code 250 but got an empty response in public_html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:448
I've tried requeuing my emails several times now since yesterday, but I keep on receiving the same error when it attempts to send. This worked flawlessly before for almost a year, so I'm a bit confused what is causing this issue. I haven't changed any credentials nor changed any code or configuration recently.
My mail settings are as follows:
MAIL_DRIVER=smtp
MAIL_HOST="smtp-relay.gmail.com"
MAIL_PORT=587
MAIL_USERNAME="my#user.name"
MAIL_PASSWORD="myapppassword"
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="my#from.address"
MAIL_FROM_NAME="My Name"
I've doubled checked in my Google Admin that both the IPv4 address as well as the IPv6 address of my server are whitelisted and the SMTP relay service is enabled. I also created a new App password within my Google account to see if that would fix the problem - but no luck there.
I've also cleared the config cache (and have tried php artisan config:cache) and tried restarting supervisor which runs the worker running the task for the email queue. I've also tried requeueing the emails one by one in case I triggered some kind of throttling, but to no avail. By no means is my website sending many emails, about a 100 a month, well within the limits posed by my email account. (And I currently got <10 stuck in queue.)
As a last resort I turned off SMTP verification and TLS encryption in the Google Admin, so the only requirement for using the SMTP was having the IP address whitelisted (which it is). But this didn't work either, so I've switched SMTP verification and TLS encryption back on again as a requirement.
Finally; I ran a composer update, but that didn't fix the problem either.
I've found some other older threads on Stackoverflow with a similar problem, but I had already tried all offered solutions as described above.
What am I missing?

i think you need change mail port to 25 like this :
MAIL_PORT=25

Just faced same issue.
In my case SMTP sending worked when I tried to send an email without queues.
But when I tried to send same email with same config using queue, I got error that looks like:
[2021-02-15 12:43:24] local.ERROR: Expected response code 250 but got an empty response {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response at /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:448)
[stacktrace]
#0 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(345): Swift_Transport_AbstractSmtpTransport->assertResponseCode('', Array)
#1 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(305): Swift_Transport_AbstractSmtpTransport->executeCommand('HELO [127.0.0.1...', Array, Array, false, NULL)
#2 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(368): Swift_Transport_EsmtpTransport->executeCommand('HELO [127.0.0.1...', Array)
#3 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(341): Swift_Transport_AbstractSmtpTransport->doHeloCommand()
#4 /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(148): Swift_Transport_EsmtpTransport->doHeloCommand()
After long research I've found that issue is related with HELO command itself.
As you can clearly see in the log, for some reason (probably server hostname) there is 127.0.0.1 IP address, which Google is blocking.
How I resolved that:
So to resolve that, I've added one little line in my artisan file:
$_SERVER['SERVER_NAME'] = 'mydomain.com';
So my artisan file looks like this now:
#!/usr/bin/env php
<?php
$_SERVER['SERVER_NAME'] = 'mydomain.com';
define('LARAVEL_START', microtime(true));
...

Spoke with Google Workspace rep
As a temporary solution they asked to use
smtp.gmail.com instead of smtp-relay.gmail.com
Worked on 2 of our projects.
P.S. The limit is 130 emails per account on Workspace (former Gsuite)
for example if you have 5 users, 5x130=650
What the rep said haha :)

Related

Expected response code "250" but got code "550", with message "550-Requested action not taken: mailbox unavailable 550 Sender address has null MX"

I have a Laravel 9.x site that I'm hosting on IONOS (shared-hosting).
In my site, I utilize mail a lot. So I'm sending mails to my customer frequently. While developing the system - I was using MailTrap.io - but for deployment, I need all the mails to go to my IONOS Mail Account i.e info#domain.com - for that, I need to use IONOS' Mail Configuration.
Following is my mail config (censoring out private info):
MAIL_MAILER=smtp
MAIL_HOST=smtp.ionos.com
MAIL_PORT=587
MAIL_USERNAME=############.com
MAIL_PASSWORD=################
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="${APP_NAME}"
MAIL_FROM_ADDRESS=#############.com
This is the error I'm getting:
This is the piece of manual documentation I got from IONOS' Dashboard:
How do I fix this? What is causing this issue? Like I mentioned before, all of it was working fine with MailTrap.io - so I'm really curious what am I doing wrong.
Thank you :)
As per ionos.com documentation
550 Sender address has null MX
The domain from which you send email has a configured No Service MX record (zero MX). The IONOS SMTP recipient rejects such emails
Delete the No Service MX entry in the DNS settings of your domain. For more information about a No Service MX entry, see RFC 7505.

Am experiencing issues with email delivery-"response code 250 but got code '550' "

I am using Exim mail server for my smtp and experiencing an issue when sending emails from the server if the connection is instantiated from within the server. However if I try authenticating from outside, emails are sent without any problems. Am using Laravel which ships with Swift mailer. This is the error laravel is giving out.
production.ERROR: Expected response code 250 but got code "550", with message "550 127.0.0.1 is _my_ address
Exim's log also has a similar error;
H=localhost [127.0.0.1] X=TLSv1:ECDHE-RSA-AES256-SHA:256 CV=no rejected MAIL <no-reply#mydomain.com>: 127.0.0.1 is _my_ address
My .env file has credentials set up correctly as follows
MAIL_DRIVER=smtp
MAIL_HOST=mydomain.com
MAIL_PORT=587
MAIL_USERNAME=no-reply#mydomain.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
The code used to send the emails is as below;
Mail::to('admin#mydomain.com')->send(new AlertEmail($information));
What am wondering is,could the problem be caused by trying to send the email to addresses within the same domain? I hope someone can help me out. Am almost going crazy.
NB: Roundcube is sending emails fine.

LARAVEL MAIL: Expected response code 250 but got code "", with message ""

I can send email in my localhost, but when I put it in our remote server I get this error:
I don't know what the problem is. Anyone?
I used the laravel default mail driver which is swiftmailer.
Check your gmail: in settings, enable access for less secure apps and it will work.

Google checkout callback can't seem to reach https server

I am trying to implement Google Check out (GCO) on a new server, the process seemed to work fine on the old server.
The error from GCO integration console is the timeout error you might expect if there is load on the server and/or the response takes longer than 3 seconds to respond.
To perform a test (not integrating with my database), I have set some code to send an email to me instead. If I hit the https url manually, I get the email and I can see an output to the screen. If I then leave it as that, Google still returns the Timeout error and I don't get an email. So I have doubts as to whether google is even able to hit the https url.
I did temporarily attempt to use the unsecure url for testing and indeed I received the email, however this solution isn't the route we've developed for, so the problem is something to do with the secure url specifically.
I have looked into the certificate which is a UTN-USERFirst-Hardware which is listed as accepted on http://checkout.google.com/support/sell/bin/answer.py?answer=57856 . I have also tried to temporarily disable the firewall with no joy. Does anyone have any sugestions?
Good to hear you figured out the problem.
I'm adding the links below to add a litle more context for future readers about how Google Checkout uses HTTP Basic Authentication:
http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API.html#urls_for_posting
http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API.html#https_auth_scheme
http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_API_Notification_API.html#Receiving_and_Processing_Notifications

codeigniter mail sending error 451

Can any one tell me why I'm getting this error with codeigniter when it comes to sending mail.
some time it work fine some times i get this error
451 Please try again later
The following SMTP error was encountered: 451 Please try again later
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Are you sure your SMTP server is working fine at the time you get this error? If it works sometimes, then that means that your configuration is probably fine. I'd deploy the code of a test server online and then run your code to see if its really a configuration problem or maybe a problem with the SMTP host that you're trying to send the mail through.

Resources