Files

44 lines
1.8 KiB
C++
Raw Permalink Normal View History

2020-02-29 19:25:13 -08:00
#include "__SMTP_EHLO.h"
2022-07-08 19:30:00 -07:00
#include "SMTPServer.h"
#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
// 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();
2022-07-08 19:30:00 -07:00
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;
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
}