S
S
Stanislav2016-07-28 10:40:49
symfony
Stanislav, 2016-07-28 10:40:49

Why is there a HELO/EHLO argument invalid error when sending mail via smtp google via swiftmailer?

I ran into a rather strange situation. We have a project whose versions depend on the year. For example: 2016.example.ru, 2015.example.ru, etc. Each version is in its own folder with the year number. Nginx has a section that handles the request:
server {
listen 80;
server_name "~^(?\d{4})\.example\.ru$";
In order not to create a bunch of sections for each year, we used a regular expression in the server name.
Project routing works as it should. BUT when sending mail through the symfony swiftmailer component configured to google smtp, an incomprehensible error occurs:
Failed to send notification [email protected] Expected response code 250 but got code "", with message "" Log data: ++ Starting Swift_Transport_EsmtpTransport << 220 smtp.gmail.com ESMTP z78sm1692032lfd.2 - gsmtp >> EHLO ~^( ?\d{4})\.example\.ru$ << 501-5.5.4 HELO/EHLO argument "~^(?\d{4})\.example\.ru$" invalid, closing 501-5.5 .4 connection. 501 5.5.4 https://support.google.com/mail/?p=helo z78sm1692032lfd.2 - gsmtp !! Expected response code 250 but got code "501", with message "501-5.5.4 HELO/EHLO argument "~^(?\d{4})\.example\.ru$" invalid, closing 501-5.5.4 connection.501 5.5.4 https://support.google.com/mail/?p=helo z78sm1692032lfd.2 - gsmtp " (code: 501) >> HELO ~^(?\d{4})\.example\ .ru$ << !!
Apparently, when answering Google, our server returns the host value from the nginx config: "~^(?\d{4})\.example\.ru$"
Sending mail does not work on the production server, everything is top-notch on local servers. They also tested with telnet, everything is fine.
Can you please tell me where to look for the problem or has someone already encountered this? How does the value of the regular expression appear in the server's response?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav, 2016-07-28
@stascer

Solved the problem. The bottom line is that nginx substitutes this regular expression into the value of the server variable SERVER_NAME, which in turn is passed to php.
https://github.com/swiftmailer/swiftmailer/issues/453
The solution is: fastcgi_param SERVER_NAME $year.example.ru;

S
SergeySL, 2016-07-28
@SergeySL

Are the quotes in server_name really needed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question