32 const std::string & domain ,
const GNet::Address & peer_address ) :
33 m_code_ident(code_ident) ,
34 m_anonymous(anonymous) ,
35 m_with_received_line(with_received_line) ,
37 m_peer_address(peer_address)
39 G_ASSERT( !domain.empty() ) ;
41 m_domain =
"localhost" ;
44std::string GSmtp::ServerText::greeting()
const
46 std::string greeting_domain = m_domain ;
49 std::string(
"greeting") :
50 greeting_domain.append(
" -- ",4U).append(m_code_ident).append(
" -- Service ready") ;
53std::string GSmtp::ServerText::hello(
const std::string & )
const
55 std::string greeting_domain = m_domain ;
58 std::string(
"smtp says hello") :
59 greeting_domain.append(
" says hello") ;
62std::string GSmtp::ServerText::received(
const std::string & smtp_peer_name ,
63 bool authenticated ,
bool secure ,
const std::string & protocol ,
const std::string & cipher )
const
65 return m_with_received_line ? receivedLine( smtp_peer_name , m_peer_address.hostPartString() , m_domain ,
66 authenticated , secure , protocol , cipher ) :
std::string() ;
69std::string GSmtp::ServerText::receivedLine(
const std::string & smtp_peer_name ,
70 const std::string & peer_address ,
const std::string & receivedline_domain ,
71 bool authenticated ,
bool secure ,
const std::string & ,
const std::string & cipher_in )
78 const std::string esmtp = std::string(
"ESMTP") + (secure?
"S":
"") + (authenticated?
"A":
"") ;
81 std::string cipher = secure ?
86 std::ostringstream ss ;
88 <<
"Received: from " << peer_name
90 <<
"[" << peer_address <<
"]"
91 <<
") by " << receivedline_domain <<
" with " << esmtp
92 << (cipher.empty()?
"":
" tls ") << cipher
94 << date.weekdayName(
true) <<
", "
95 << date.monthday() <<
" "
96 << date.monthName(
true) <<
" "
98 << time.hhmmss(
":") <<
" "
The GNet::Address class encapsulates a TCP/UDP transport address.
ServerText(const std::string &code_ident, bool anonymous, bool with_received_line, const std::string &greeting_and_receivedline_domain, const GNet::Address &peer_address)
Constructor.
An encapsulation of 'struct std::tm'.
static Offset offset(SystemTime)
Returns the offset in seconds between UTC and localtime as at the given system time.
static std::string offsetString(Offset offset)
Converts the given utc/localtime offset into a five-character "+/-hhmm" string.
A day-month-year date class.
static std::string replaced(const std::string &s, char from, char to)
Returns the string 's' with all occurrences of 'from' replaced by 'to'.
static std::string toPrintableAscii(const std::string &in, char escape='\\')
Returns a 7-bit printable representation of the given input string.
static std::string_view alnum_() noexcept
Returns alnum() with an additional trailing underscore character.
static std::string only(std::string_view allow_chars, std::string_view s)
Returns the 's' with all occurrences of the characters not appearing in the first string deleted.
Represents a unix-epoch time with microsecond resolution.
static SystemTime now()
Factory function for the current time.
BrokenDownTime local() const
Returns the locale-dependent local broken-down time.
A simple time-of-day (hh/mm/ss) class.