Search code examples
c++linuxsmtpmail-server

Gmail sends EHLO..QUIT immediately to custom SMTP/MTA server


I'm trying to write a simple receiving mail server (MTA) in C++ on Linux, I've gotten as far as when I try to send mail to it from my Gmail account, a Google server connects, but then quits right after. I have no idea what I'm missing. The current communication looks like:

S: 220 mx.domain.com ESMTP<CR><LF>
C: EHLO mail.google.com<CR><LF>QUIT<CR><LF>
S: 250 mx.domain.com at your service<CR><LF>221 Bye<CR><LF>

I'm very confused by the fact the Google mail server is sending both EHLO and QUIT in the same request. And of course it never sends the actual mail. Any ideas as to why it quits?


Solution

  • In my case it was because the server sent the response to the client padded with '\0' after capping to the correct response length everything works as intended.