sptk2 logo
SPTK Home Page
BaseMailConnect.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/Buffer.h>
30#include <sptk5/net/MailMessageBody.h>
31
32#include <string>
33
34namespace sptk {
35
46class SP_EXPORT BaseMailConnect
47{
48public:
52 BaseMailConnect() = default;
53
57 virtual ~BaseMailConnect() = default;
58
63 String from() const noexcept
64 {
65 return m_from;
66 }
67
74 void from(const String& addr)
75 {
76 m_from = addr;
77 }
78
83 String to() const noexcept
84 {
85 return m_to;
86 }
87
94 void to(const String& addr)
95 {
96 m_to = addr;
97 }
98
104 String cc() const noexcept
105 {
106 return m_cc;
107 }
108
115 void cc(const String& addr)
116 {
117 m_cc = addr;
118 }
119
125 String bcc() const noexcept
126 {
127 return m_bcc;
128 }
129
135 void bcc(const String& addr)
136 {
137 m_bcc = addr;
138 }
139
144 String subject() const noexcept
145 {
146 return m_subject;
147 }
148
153 void subject(const String& subj)
154 {
155 m_subject = subj;
156 }
157
162 String body() const noexcept
163 {
164 return m_body.text();
165 }
166
172 void body(const String& body, bool smtp)
173 {
174 m_body.text(body, smtp);
175 }
176
182 String attachments() const noexcept
183 {
184 return m_attachments;
185 }
186
192 void attachments(const String& attachments)
193 {
194 m_attachments = attachments;
195 }
196
202 const Buffer& messageBuffer() const noexcept
203 {
204 return m_messageBuffer;
205 }
206
211 void mimeMessage(Buffer& buffer);
212
217 virtual void sendMessage() = 0;
218
219protected:
223 static void mimeFile(const String& fileName, const String& fileAlias, std::stringstream& message);
224
225private:
226 String m_from;
227 String m_to;
228 String m_cc;
229 String m_bcc;
230 String m_subject;
231 MailMessageBody m_body;
232 String m_attachments;
233 Buffer m_messageBuffer;
234};
238} // namespace sptk
Base mail socket.
Definition: BaseMailConnect.h:47
void to(const String &addr)
Definition: BaseMailConnect.h:94
String bcc() const noexcept
Definition: BaseMailConnect.h:125
virtual ~BaseMailConnect()=default
String from() const noexcept
Definition: BaseMailConnect.h:63
virtual void sendMessage()=0
void bcc(const String &addr)
Definition: BaseMailConnect.h:135
String cc() const noexcept
Definition: BaseMailConnect.h:104
void cc(const String &addr)
Definition: BaseMailConnect.h:115
void subject(const String &subj)
Definition: BaseMailConnect.h:153
String to() const noexcept
Definition: BaseMailConnect.h:83
void attachments(const String &attachments)
Definition: BaseMailConnect.h:192
void body(const String &body, bool smtp)
Sets the current plain text part of e-mail message.
Definition: BaseMailConnect.h:172
static void mimeFile(const String &fileName, const String &fileAlias, std::stringstream &message)
void from(const String &addr)
Definition: BaseMailConnect.h:74
String attachments() const noexcept
Definition: BaseMailConnect.h:182
String subject() const noexcept
Definition: BaseMailConnect.h:144
String body() const noexcept
Definition: BaseMailConnect.h:162
void mimeMessage(Buffer &buffer)
const Buffer & messageBuffer() const noexcept
Definition: BaseMailConnect.h:202
Definition: Buffer.h:51
Definition: MailMessageBody.h:54
Definition: String.h:49

Fri Oct 14 2022 09:58:31: SPTK 5.4.1