NAWA 0.9
Web Application Framework for C++
SmtpMailer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2022 Tobias Flaig.
3 *
4 * This file is part of nawa.
5 *
6 * nawa is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License,
8 * version 3, as published by the Free Software Foundation.
9 *
10 * nawa is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with nawa. If not, see <https://www.gnu.org/licenses/>.
17 */
18
24#ifndef NAWA_SMTPMAILER_H
25#define NAWA_SMTPMAILER_H
26
30#include <string>
31
32namespace nawa::mail {
33 class SmtpMailer {
35
36 public:
45 enum class TlsMode {
46 NONE,
47 SMTPS,
50 };
51
53
67 explicit SmtpMailer(std::string serverDomain = "localhost", unsigned int serverPort = 25,
68 TlsMode serverTlsMode = TlsMode::NONE, bool verifyServerTlsCert = true,
69 std::string authUsername = "",
70 std::string authPassword = "", long connectionTimeout = 10000);
71
81 void setServer(std::string domain, unsigned int port = 25, TlsMode tlsMode = TlsMode::NONE,
82 bool verifyTlsCert = true);
83
89 void setAuth(std::string username, std::string password);
90
95 void setConnectionTimeout(long timeout);
96
120 void enqueue(std::shared_ptr<Email> email, EmailAddress to,
121 std::shared_ptr<EmailAddress> from,
122 std::shared_ptr<ReplacementRules> replacementRules = std::shared_ptr<ReplacementRules>());
123
136 void bulkEnqueue(std::shared_ptr<Email> email, std::vector<EmailAddress> recipients,
137 std::shared_ptr<EmailAddress> from,
138 std::shared_ptr<ReplacementRules> replacementRules = std::shared_ptr<ReplacementRules>());
139
143 void clearQueue();
144
150 void processQueue() const;
151 };
152}// namespace nawa::mail
153
154#endif//NAWA_SMTPMAILER_H
Structure representing an email address.
Base structure for emails.
void setConnectionTimeout(long timeout)
Definition: SmtpMailer.cpp:114
void processQueue() const
Definition: SmtpMailer.cpp:134
void bulkEnqueue(std::shared_ptr< Email > email, std::vector< EmailAddress > recipients, std::shared_ptr< EmailAddress > from, std::shared_ptr< ReplacementRules > replacementRules=std::shared_ptr< ReplacementRules >())
Definition: SmtpMailer.cpp:124
void setServer(std::string domain, unsigned int port=25, TlsMode tlsMode=TlsMode::NONE, bool verifyTlsCert=true)
Definition: SmtpMailer.cpp:102
SmtpMailer(std::string serverDomain="localhost", unsigned int serverPort=25, TlsMode serverTlsMode=TlsMode::NONE, bool verifyServerTlsCert=true, std::string authUsername="", std::string authPassword="", long connectionTimeout=10000)
Definition: SmtpMailer.cpp:95
void enqueue(std::shared_ptr< Email > email, EmailAddress to, std::shared_ptr< EmailAddress > from, std::shared_ptr< ReplacementRules > replacementRules=std::shared_ptr< ReplacementRules >())
Definition: SmtpMailer.cpp:118
void setAuth(std::string username, std::string password)
Definition: SmtpMailer.cpp:109
Macros for frequently used patterns.
#define NAWA_DEFAULT_DESTRUCTOR_DEF(Class)
Definition: macros.h:34
#define NAWA_PRIVATE_DATA()
Definition: macros.h:30