Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EHLO/HELO sent regardless of server's ready state #517

Closed
f0o opened this issue Oct 1, 2015 · 8 comments
Closed

EHLO/HELO sent regardless of server's ready state #517

f0o opened this issue Oct 1, 2015 · 8 comments

Comments

@f0o
Copy link

f0o commented Oct 1, 2015

Hi,

We use PHPMailer to transport our emails to external SMTPd's.

Some SMTPds dont answer in time, so the get_lines() call after connect() returns empty. However PHPMailer sends his EHLO/HELO before the SMTPd asks for it resulting in mail rejection by RFC Standards.

I.e. Exim4 reports SMTP protocol synchronization error (input sent without waiting for greeting) and closes the connection afterwards.

We use PHPMailer 5.2.7 but I checked the current upstream code in 5.2.13 and I couldnt find any wait code there either.

Cheers,
f0o

@cusco
Copy link

cusco commented Oct 1, 2015

Hi,

Just so you know, I see this happening with Exim4 on Debian wheezy

exim --version

Exim version 4.80 #2 built 24-Jul-2014 03:28:02
Copyright (c) University of Cambridge, 1995 - 2012
(c) The Exim Maintainers and contributors in ACKNOWLEDGMENTS file, 2007 - 2012
Berkeley DB: Berkeley DB 5.1.29: (October 25, 2011)
Support for: crypteq iconv() IPv6 PAM Perl Expand_dlfunc GnuTLS move_frozen_messages Content_Scanning DKIM Old_Demime
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmjz dbmnz dnsdb dsearch ldap ldapdn ldapm mysql nis nis0 passwd pgsql sqlite
Authenticators: cram_md5 cyrus_sasl dovecot plaintext spa
Routers: accept dnslookup ipliteral iplookup manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore/mbx autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
Configuration file is /etc/exim4/exim4.conf

the full error message in the log is:

 SMTP protocol synchronization error (input sent without waiting for greeting): rejected connection from H=[10.100.100.22]:58366 I=[10.100.100.35]:25 input="\026\003\001\002"

@Synchro
Copy link
Member

Synchro commented Oct 1, 2015

This is handled by the connect method in the SMTP class, around here. The timeout is set in the socket options. As you can see, if it fails to connect or the server does not respond (e.g. if it's using a greetdelay), it will give up the transaction altogether, and should never get as far as sending HELO/EHLO.

The SMTP timeouts are set to the RFC2821 recommendation of 5 minutes. Is your server taking longer than that?

I don't see how it's getting past those things - could you try tracing what's happening in your case to see how it's saying that the connection is successful when it isn't?

@cusco
Copy link

cusco commented Oct 1, 2015

Hi Synchro,

Thank you for your reply.

That line you showed, seems to evaluate if it is a resource, and it is.

However you send the ehlo/helo before the server greets.

In this case the server takes about a second to greet,

[e-mail: ~]# echo ehlo test.com |nc localhost 25
554 SMTP synchronization error

[e-mail: ~]# echo ehlo test.com && sleep 0.5 |nc localhost 25
ehlo test.com
220 domain.com ESMTP Exim 4.80 Thu, 01 Oct 2015 16:32:55 +0100

I supose one must read the greeting line before sending the helo. I believe this is the problem, but did not debug it

@Synchro
Copy link
Member

Synchro commented Oct 2, 2015

The code does wait - after connecting successfully, it then waits for input from the server. What do you see if you set SMTPDebug = 4?

@Synchro
Copy link
Member

Synchro commented Nov 18, 2015

Did you solve this?

@f0o
Copy link
Author

f0o commented Nov 19, 2015

Bump @cusco

On 18 November 2015 08:49:40 CET, Marcus Bointon notifications@github.com wrote:

Did you solve this?


Reply to this email directly or view it on GitHub:
#517 (comment)

@cusco
Copy link

cusco commented Nov 19, 2015

Hi.

Sorry. Did not solve it. I went somewhere in the class and added a sleep of 2 seconds and it sends email now..

I could tell you I would look all that up later and even test it, but my time is limited right now..

So if there is no one else with this issue, you could perhaps close it. I can always re open at a later time if needed

Thank you for your attention

Sent from my iPhone

On 19/11/2015, at 07:02, Daniel Preussker notifications@github.com wrote:

Bump @cusco

On 18 November 2015 08:49:40 CET, Marcus Bointon notifications@github.com wrote:

Did you solve this?


Reply to this email directly or view it on GitHub:
#517 (comment)

Reply to this email directly or view it on GitHub.

@Synchro
Copy link
Member

Synchro commented Nov 19, 2015

The code definitely waits for input, with a long timeout. Given that it still breaks, it suggests that the server may be sending a blank line or something before it sends its greeting. I'll close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants