join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
smtp_message.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_SERVICES_SMTP_MESSAGE_HPP
26#define JOIN_SERVICES_SMTP_MESSAGE_HPP
27
28// libjoin.
29#include <join/version.hpp>
30#include <join/error.hpp>
31
32// C++.
33#include <iostream>
34#include <vector>
35
36namespace join
37{
42 {
43 public:
47 SmtpSender () = default;
48
53 SmtpSender (const std::string& address);
54
60 SmtpSender (const std::string& address, const std::string& name);
61
66 SmtpSender (const SmtpSender& other);
67
73 SmtpSender& operator= (const SmtpSender& other);
74
79 SmtpSender (SmtpSender&& other);
80
87
91 virtual ~SmtpSender () = default;
92
97 void address (const std::string& addr);
98
103 const std::string& address () const;
104
109 void realName (const std::string& name);
110
115 const std::string& realName () const;
116
121 bool empty () const;
122
123 protected:
125 std::string _address;
126
128 std::string _name;
129 };
130
137 std::ostream& operator<< (std::ostream& out, const SmtpSender& sender);
138
143 {
144 public:
154
158 SmtpRecipient () = default;
159
165 SmtpRecipient (const std::string& address, Type t = Recipient);
166
173 SmtpRecipient (const std::string& address, const std::string& name, Type t = Recipient);
174
179 SmtpRecipient (const SmtpRecipient& other);
180
187
193
200
204 virtual ~SmtpRecipient () = default;
205
210 void type (Type t);
211
216 Type type () const;
217
218 protected:
221 };
222
224 using SmtpRecipients = std::vector<SmtpRecipient>;
225
230 {
231 public:
235 SmtpMessage () = default;
236
241 SmtpMessage (const SmtpMessage& other);
242
248 SmtpMessage& operator= (const SmtpMessage& other);
249
254 SmtpMessage (SmtpMessage&& other);
255
262
266 virtual ~SmtpMessage () = default;
267
272 void sender (const SmtpSender& from);
273
278 const SmtpSender& sender () const;
279
284 void addRecipient (const SmtpRecipient& to);
285
290 void addRecipient (SmtpRecipient&& to);
291
296 const SmtpRecipients& recipients () const;
297
302 void subject (const std::string& subj);
303
308 const std::string& subject () const;
309
314 void content (const std::string& message);
315
320 const std::string& content () const;
321
327 int writeHeaders (std::ostream& out) const;
328
334 int writeContent (std::ostream& out) const;
335
336 protected:
339
342
344 std::string _subject;
345
347 std::string _content;
348 };
349}
350
351#endif
mail message.
Definition smtp_message.hpp:230
int writeContent(std::ostream &out) const
write content to the given output stream.
Definition smtp_message.cpp:449
std::string _subject
mail sender.
Definition smtp_message.hpp:344
virtual ~SmtpMessage()=default
destroy the SmtpMessage instance.
void addRecipient(const SmtpRecipient &to)
add mail recipient.
Definition smtp_message.cpp:305
const std::string & subject() const
get mail subject.
Definition smtp_message.cpp:341
const SmtpRecipients & recipients() const
get mail recipients.
Definition smtp_message.cpp:323
SmtpSender _sender
mail sender.
Definition smtp_message.hpp:338
SmtpRecipients _recipients
mail recipients.
Definition smtp_message.hpp:341
int writeHeaders(std::ostream &out) const
write header to the given output stream.
Definition smtp_message.cpp:368
SmtpMessage()=default
create the SmtpMessage instance.
SmtpMessage & operator=(const SmtpMessage &other)
assign the SmtpMessage instance by copy.
Definition smtp_message.cpp:249
std::string _content
mail content.
Definition smtp_message.hpp:347
const SmtpSender & sender() const
get mail sender
Definition smtp_message.cpp:296
const std::string & content() const
get mail content.
Definition smtp_message.cpp:359
mail recipient.
Definition smtp_message.hpp:143
Type
recipient type.
Definition smtp_message.hpp:149
@ CCRecipient
Definition smtp_message.hpp:151
@ Recipient
Definition smtp_message.hpp:150
@ BCCRecipient
Definition smtp_message.hpp:152
SmtpRecipient & operator=(const SmtpRecipient &other)
assign the SmtpRecipient instance by copy.
Definition smtp_message.cpp:187
Type _type
recipient type.
Definition smtp_message.hpp:220
virtual ~SmtpRecipient()=default
destroy the SmtpRecipient instance.
SmtpRecipient()=default
create the SmtpRecipient instance.
Type type() const
get recipient type.
Definition smtp_message.cpp:228
mail sender.
Definition smtp_message.hpp:42
SmtpSender()=default
create the SmtpSender instance.
virtual ~SmtpSender()=default
destroy the SmtpSender instance.
SmtpSender & operator=(const SmtpSender &other)
assign the SmtpSender instance by copy.
Definition smtp_message.cpp:71
const std::string & realName() const
get real name.
Definition smtp_message.cpp:130
std::string _name
name.
Definition smtp_message.hpp:128
const std::string & address() const
get address.
Definition smtp_message.cpp:112
std::string _address
address.
Definition smtp_message.hpp:125
bool empty() const
check if empty.
Definition smtp_message.cpp:139
Definition acceptor.hpp:32
std::vector< SmtpRecipient > SmtpRecipients
mail recipient list.
Definition smtp_message.hpp:224
std::ostream & operator<<(std::ostream &os, const BasicLinkLayerEndpoint< Protocol > &endpoint)
push endpoint representation into a stream.
Definition endpoint.hpp:258