NAWA  0.8
Web Application Framework for C++
SmtpMailer.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2019-2021 Tobias Flaig.
8  *
9  * This file is part of nawa.
10  *
11  * nawa is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License,
13  * version 3, as published by the Free Software Foundation.
14  *
15  * nawa is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with nawa. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef NAWA_SMTPMAILER_H
25 #define NAWA_SMTPMAILER_H
26 
27 #include <nawa/internal/macros.h>
28 #include <nawa/mail/Email/Email.h>
29 #include <nawa/mail/EmailAddress.h>
30 #include <string>
31 
32 namespace 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