#include "__SMTP_EHLO.h" #include "SMTPServer.h" #include "SMTPSyntax.h" namespace mail { int __SMTP_EHLO::processCommand(coreutils::ZString &request, SMTPSession &session, SMTPServer &server) { // RFC 5321 4.1.1.1 requires a domain/address-literal argument. std::string arg = SMTPSyntax::argument(line(request)); if (arg.empty()) { session.out << "501 5.5.4 Syntax: EHLO hostname" << CRLF; return 1; } // EHLO also aborts any transaction in progress (RFC 5321 4.1.4). session.greeted = true; session.esmtp = true; session.resetTransaction(); session.clientDomainName = arg.substr(0, arg.find(' ')).c_str(); session.out << "250-" << server.hostName << CRLF; // Multiple pipelined command lines arriving in one read are // processed in order (TCPSocket::onDataReceived loops over every // complete line it has), and replies go out in the same order. session.out << "250-PIPELINING" << CRLF; // Message bodies are stored byte-for-byte; no 7-bit stripping. session.out << "250-8BITMIME" << CRLF; // Declared in MAIL FROM (SIZE=) and enforced while receiving DATA. session.out << "250-SIZE " << (long)SMTPServer::maxMessageSize << CRLF; // Every 2xx/4xx/5xx reply after this one carries a RFC 3463 code. session.out << "250-ENHANCEDSTATUSCODES" << CRLF; // RFC 3207 4.2: only while the session is still in clear text. if (server.startTLSContext && !session.isTLS()) session.out << "250-STARTTLS" << CRLF; // RFC 4954 4/14: no plain-text password mechanisms over an // unencrypted connection when encryption is available. if (server.authAllowed(session)) session.out << "250-AUTH PLAIN LOGIN" << CRLF; session.out << "250 HELP" << CRLF; return 1; } }