sptk2 logo
SPTK Home Page
SmtpConnect.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/Logger.h>
30#include <sptk5/Strings.h>
31#include <sptk5/net/BaseMailConnect.h>
32#include <sptk5/net/TCPSocket.h>
33
34#include <string>
35
36namespace sptk {
37
50class SP_EXPORT SmtpConnect : public BaseMailConnect
51 , public TCPSocket
52{
53public:
58 explicit SmtpConnect(Logger* log = nullptr);
59
68 int command(const String& cmd, bool encodeCommand = false, bool decodeResponse = false);
69
74 {
75 return m_response;
76 }
77
83 void cmd_auth(const String& user, const String& password);
84
91 void cmd_send();
92
96 void cmd_quit();
97
104 void sendMessage() override;
105
106protected:
114 void sendCommand(String cmd, bool encode = false);
115
122 int getResponse(bool decode = false);
123
129 static String mime(const Buffer& buffer);
130
136 static String mime(const String& s);
137
143 static String unmime(const String& s);
144
145private:
146 Logger* m_log;
147 Strings m_response;
148};
152} // namespace sptk
Base mail socket.
Definition: BaseMailConnect.h:47
Definition: Buffer.h:51
A log that sends all the log messages into another log.
Definition: Logger.h:53
SMTP socket.
Definition: SmtpConnect.h:52
int getResponse(bool decode=false)
Retrieves the server response after the command into internal Strings buffer.
void cmd_send()
Sends the message.
static String mime(const Buffer &buffer)
Mime-encodes the buffer.
SmtpConnect(Logger *log=nullptr)
Default constructor.
void sendCommand(String cmd, bool encode=false)
Sends command using SMTP protocol.
void cmd_auth(const String &user, const String &password)
Logs in to the server host()
Strings & response()
The response from the server - makes sence after calling any command.
Definition: SmtpConnect.h:73
static String unmime(const String &s)
Mime-decodes the string.
void sendMessage() override
Sends the message.
int command(const String &cmd, bool encodeCommand=false, bool decodeResponse=false)
static String mime(const String &s)
Mime-encodes the string.
Definition: String.h:49
Definition: Strings.h:52
Definition: TCPSocket.h:165

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