Error Expected response code 250 but got code "", with message "" when $_SERVER['SERVER_NAME'] has unsupported symbols by RFC #992
Comments
I see it is obsolete bug. In current version But still variable |
I'm getting this when run from php-cli on a cron job. When run through Apache, the script mails through gmail-relay with TLS just fine. On cron, this is the exact error I'm seeing, perhaps because there is no SERVER_NAME to pass to it? I even discovered cron was running PHP 5.5.30 version 7.0.22 in Apache because of cPanel. My cron now forces /opt/php70/bin/php with the same 7.0.22 php.ini as Apache reports... but this error persists. Ideas? This just started yesterday, perhaps when cPanel got updated on my managed VPS. |
It seems |
And of course since I'm sleep deprived, I see my error is slightly different:
|
I have same error randomly Expected response code 250 but got code "", with message "" For the same mail, I can retry to send immediatly after this error and it work.... |
This is only php-cli; when through Apache is sends reliably. |
This is PHP 7.0.22... smtp-relay.gmail.com via G Suite, TLS on 587 using SMTP authentication. Always works via Apache access to the script. I now var_export the $transport and $mailer to a log file, but I'm not sure what to look for. When it fails, it is:
|
I moved from smtp-relay.gmail.com (tls on 587 with SMTP auth) to my localhost using ssl on 465, still with smtp auth, and now it's 10/10 success. It's not liking TLS on Gmail for some reason on php-cli. Hrm. |
I believe it's something with TLS. I had my G Suite SMTP Relay set to require TLS. That requires port 587. When the PHP is accessed via Apache, this always worked. When via php-cli or cron, this was sporadic. I turned off Require TLS in G Suite SMTP Relay... set my SwiftMailer to $transport = (new Swift_SmtpTransport('smtp-relay.gmail.com', 465, 'ssl')) and now it's a consistent success in php-cli or cron. |
Switching to SSL on port 465 (and disable "TLS required" on G SUITE) don't solve the problem for me. |
#545 does seem to reflect my issue. I was on swiftmailer 5.x and this started to occur, I think my server got a significant upgrade this week (a managed VPS), and the cron version of my script quit working Thursday. I discovered php-cli was still PHP 5.5.30, so it wouldn't have worked with swiftmailer 6.0.1. The first true cron test of the script is in 29 minutes. |
Well, the cron ran, this is what I got in email... HELO doesn't like 127.0.0.1 it seems: |
Which brings my issue full circle back to this issue #992 again. Failing because of SERVER_NAME when run as cron instead of Apache. |
Here is my debug trace with same problem.
|
I just found that SERVER_NAME is not accessible to php-cli. And I'm guessing Gmail spits out 127.0.0.1 for HELO. |
I concur. With gethostname() the cron worked with TLS on 587 to smtp-relay.gmail.com. |
Using |
RFC 2821 calls for HELO/EHLO to be FQDN, if possible, or fall back on IP in brackets. Google may have a policy to reject [127.0.0.1] as is recommended by some documentation, such as LinuxMagic. |
I'm building a new server (CentOS 7.4) and ran into smtp-relay.gmail.com issues again... permission denied, error #13. this time: SELinux enforcement. To check:
If off, resolution:
SMTP Relay then worked. How odd that my troubleshooting brought me back to my own thread. Yay! I so adore Swiftmailer. |
For those who run into this error and can't fix it using the above solution. It's just that swiftmailer does something funky in TL;DR: Your password might be wrong. |
Hi! I got the same exception error, but the problem comes from an original exception Swift_TransportException throw inside of method _doRcptToCommand and the error is captured in the AbstractSmtpTransport::_doMailTransaction line 422: Expected response code 250/251/252 but got code "550", with the message "550 SMTP AUTH is required for message submission on port 587 After capturing the exception and store the email in the variable $failedRecipients is invoked the method reset at line 430, that method runs the comment RSET but the server does not response anything, I suppose by the previous error. This process hides the original error and maybe is a common problem with other people. A different example from another SMTP server (mail.com) is that I got an error in the same line that I told from the above comment with the error message: Expected response code 250/251/252 but got code "550", with message "550-Requested action not taken: mailbox unavailable In this case, my problem is that I never will get that exception and I need to do a special process to capture that problem. Finally, the execution of method reset in the class AbstractSmtpTransport does not throw any exception in comparison than the other SMTP server did it. |
Hi!
Thanks! |
Hi! |
I have same issue : My email are send with SMTP relay (without SSL). Can you merge a PR with last version of ?
Pierre |
@driviera I see this is an old thread but I just ran into this exact issue where SERVER_NAME is not accessible to php-cli and therefore Swiftmailer is defaulting to 127.0.0.1 and gmail is balking. Has anyone come up with a solution other than hardcoding the gethostname() change in this library? |
I got the same issue also only for above this amount of emails. gethostname() solution didn’t help. |
in my case it was because of email processing handled by queue worker, and it looks like transport is open until worker process end, so Swiftmailer send many emails in long-running connection and at some point SMTP server closes connection on timeout. if ($this->mailer->getTransport()->isStarted()) {
$this->mailer->getTransport()->stop();
} |
Observed behaviour
Got error
when variable $_SERVER['SERVER_NAME'] contains asterisk '*' and use smtp transport.
Expected behaviour
Maybe throw exception, when SERVER_NAME contains asterisk or symbols not accepted by RFC for domain address. I'm not sure.
Example
Nginx has config:
server_name *somedomain.tld
In php:
$_SERVER['SERVER_NAME'] = '*somedomain.tld'
And if try to use smtp transport, error will be fired.
The text was updated successfully, but these errors were encountered: