join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
smtp_protocol.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_SERVICES_SMTP_PROTOCOL_HPP
26#define JOIN_SERVICES_SMTP_PROTOCOL_HPP
27
28// libjoin.
29#include <join/tls_protocol.hpp>
30
31namespace join
32{
33 template <class Protocol>
35
36 template <class Protocol>
38
42 class Smtp
43 {
44 public:
45 using Transport = Tcp;
46 using Endpoint = typename Transport::Endpoint;
50
55 constexpr explicit Smtp (int family = AF_INET) noexcept
56 : _transport (family)
57 {
58 }
59
64 static inline Smtp& v4 () noexcept
65 {
66 static Smtp smtpv4 (AF_INET);
67 return smtpv4;
68 }
69
74 static inline Smtp& v6 () noexcept
75 {
76 static Smtp smtpv6 (AF_INET6);
77 return smtpv6;
78 }
79
84 constexpr int family () const noexcept
85 {
86 return _transport.family ();
87 }
88
90 static constexpr uint16_t defaultPort = 25;
91
92 private:
94 Transport _transport;
95 };
96
103 constexpr bool operator== (const Smtp& a, const Smtp& b) noexcept
104 {
105 return a.family () == b.family ();
106 }
107
111 class Smtps
112 {
113 public:
114 using Transport = Tcp;
119
124 constexpr explicit Smtps (int family = AF_INET) noexcept
125 : _transport (family)
126 {
127 }
128
133 static inline Smtps& v4 () noexcept
134 {
135 static Smtps smtpsv4 (AF_INET);
136 return smtpsv4;
137 }
138
143 static inline Smtps& v6 () noexcept
144 {
145 static Smtps smtpsv6 (AF_INET6);
146 return smtpsv6;
147 }
148
153 constexpr int family () const noexcept
154 {
155 return _transport.family ();
156 }
157
159 static constexpr uint16_t defaultPort = 465;
160
161 private:
163 Transport _transport;
164 };
165
172 constexpr bool operator== (const Smtps& a, const Smtps& b) noexcept
173 {
174 return a.family () == b.family ();
175 }
176}
177
178#endif
basic SMTP client.
Definition smtp_protocol.hpp:34
Basic SMTPS client.
Definition smtp_protocol.hpp:37
TLS stream class.
Definition tls_stream.hpp:43
TLS decorator for stream sockets.
Definition tls_wrapper.hpp:38
SMTP protocol class (SMTP over TCP, upgradable to TLS using STARTTLS).
Definition smtp_protocol.hpp:43
typename Transport::Endpoint Endpoint
Definition smtp_protocol.hpp:46
static Smtp & v4() noexcept
get protocol suitable for IPv4 address family.
Definition smtp_protocol.hpp:64
static Smtp & v6() noexcept
get protocol suitable for IPv6 address family.
Definition smtp_protocol.hpp:74
static constexpr uint16_t defaultPort
default SMTP port.
Definition smtp_protocol.hpp:90
constexpr int family() const noexcept
get the protocol IP address family.
Definition smtp_protocol.hpp:84
constexpr Smtp(int family=AF_INET) noexcept
construct the SMTP protocol instance.
Definition smtp_protocol.hpp:55
SMTPS protocol class (SMTP over TLS).
Definition smtp_protocol.hpp:112
static constexpr uint16_t defaultPort
default SMTPS port.
Definition smtp_protocol.hpp:159
typename Transport::Endpoint Endpoint
Definition smtp_protocol.hpp:115
constexpr Smtps(int family=AF_INET) noexcept
construct the SMTPS protocol instance.
Definition smtp_protocol.hpp:124
constexpr int family() const noexcept
get the protocol IP address family.
Definition smtp_protocol.hpp:153
static Smtps & v6() noexcept
get protocol suitable for IPv6 address family.
Definition smtp_protocol.hpp:143
static Smtps & v4() noexcept
get protocol suitable for IPv4 address family.
Definition smtp_protocol.hpp:133
TCP protocol class.
Definition protocol.hpp:452
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:494
BasicInternetEndpoint< Tcp > Endpoint
Definition protocol.hpp:454
Definition acceptor.hpp:32
bool operator==(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:196