2020-02-29 19:25:13 -08:00
|
|
|
#include "__SMTP_EHLO.h"
|
2022-07-08 19:30:00 -07:00
|
|
|
#include "SMTPServer.h"
|
2026-11-02 08:57:23 -08:00
|
|
|
#include "SMTPSyntax.h"
|
2020-02-29 19:25:13 -08:00
|
|
|
|
|
|
|
|
namespace mail {
|
2022-12-07 15:00:04 -08:00
|
|
|
|
2022-07-08 19:30:00 -07:00
|
|
|
int __SMTP_EHLO::processCommand(coreutils::ZString &request, SMTPSession &session, SMTPServer &server) {
|
2022-06-29 13:34:49 -07:00
|
|
|
|
2026-11-02 08:57:23 -08:00
|
|
|
// 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;
|
2026-09-03 05:24:22 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-02 08:57:23 -08:00
|
|
|
// 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();
|
|
|
|
|
|
2022-07-08 19:30:00 -07:00
|
|
|
session.out << "250-" << server.hostName << CRLF;
|
2026-11-02 08:57:23 -08:00
|
|
|
// 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.
|
2026-09-03 05:24:22 +00:00
|
|
|
session.out << "250-PIPELINING" << CRLF;
|
2026-11-02 08:57:23 -08:00
|
|
|
// Message bodies are stored byte-for-byte; no 7-bit stripping.
|
2026-09-03 05:24:22 +00:00
|
|
|
session.out << "250-8BITMIME" << CRLF;
|
2026-11-02 08:57:23 -08:00
|
|
|
// Declared in MAIL FROM (SIZE=) and enforced while receiving DATA.
|
2026-09-03 05:24:22 +00:00
|
|
|
session.out << "250-SIZE " << (long)SMTPServer::maxMessageSize << CRLF;
|
2026-11-02 08:57:23 -08:00
|
|
|
// 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;
|
2022-07-08 19:30:00 -07:00
|
|
|
session.out << "250 HELP" << CRLF;
|
2020-04-23 14:30:00 -07:00
|
|
|
return 1;
|
2020-02-29 19:25:13 -08:00
|
|
|
}
|
2022-12-07 15:00:04 -08:00
|
|
|
|
2020-02-29 19:25:13 -08:00
|
|
|
}
|