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
114 constexpr bool operator!= (const Smtp& a, const Smtp& b) noexcept
115 {
116 return !(a == b);
117 }
118
122 class Smtps
123 {
124 public:
125 using Transport = Tcp;
130
135 constexpr explicit Smtps (int family = AF_INET) noexcept
136 : _transport (family)
137 {
138 }
139
144 static inline Smtps& v4 () noexcept
145 {
146 static Smtps smtpsv4 (AF_INET);
147 return smtpsv4;
148 }
149
154 static inline Smtps& v6 () noexcept
155 {
156 static Smtps smtpsv6 (AF_INET6);
157 return smtpsv6;
158 }
159
164 constexpr int family () const noexcept
165 {
166 return _transport.family ();
167 }
168
170 static constexpr uint16_t defaultPort = 465;
171
172 private:
174 Transport _transport;
175 };
176
183 constexpr bool operator== (const Smtps& a, const Smtps& b) noexcept
184 {
185 return a.family () == b.family ();
186 }
187
194 constexpr bool operator!= (const Smtps& a, const Smtps& b) noexcept
195 {
196 return !(a == b);
197 }
198}
199
200#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:123
static constexpr uint16_t defaultPort
default SMTPS port.
Definition smtp_protocol.hpp:170
typename Transport::Endpoint Endpoint
Definition smtp_protocol.hpp:126
constexpr Smtps(int family=AF_INET) noexcept
construct the SMTPS protocol instance.
Definition smtp_protocol.hpp:135
constexpr int family() const noexcept
get the protocol IP address family.
Definition smtp_protocol.hpp:164
static Smtps & v6() noexcept
get protocol suitable for IPv6 address family.
Definition smtp_protocol.hpp:154
static Smtps & v4() noexcept
get protocol suitable for IPv4 address family.
Definition smtp_protocol.hpp:144
TCP protocol class.
Definition protocol.hpp:471
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:513
BasicInternetEndpoint< Tcp > Endpoint
Definition protocol.hpp:473
Definition acceptor.hpp:32
bool operator==(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:186
bool operator!=(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are not equal.
Definition endpoint.hpp:198