not used
[ghsmtp.git] / Send.hpp
blob4c078e243a9598202694c107b91b5b937bb55d68
1 #ifndef SEND_DOT_HPP
2 #define SEND_DOT_HPP
4 #include "DNS.hpp"
5 #include "Mailbox.hpp"
6 #include "Sock.hpp"
7 #include "fs.hpp"
9 namespace SMTP {
10 struct Connection {
11 Connection(int fd_in, int fd_out, std::function<void(void)> read_hook)
12 : sock(fd_in,
13 fd_out,
14 read_hook,
15 std::chrono::minutes(2),
16 std::chrono::minutes(2))
20 Sock sock;
22 std::string server_id;
24 std::string ehlo_keyword;
25 std::vector<std::string> ehlo_param;
26 std::unordered_map<std::string, std::vector<std::string>> ehlo_params;
28 std::string reply_code;
30 bool greeting_ok{false};
31 bool ehlo_ok{false};
32 bool active{false}; // At least one rcp_to for this MX
34 bool has_extension(char const* name) const
36 return ehlo_params.find(name) != ehlo_params.end();
39 } // namespace SMTP
41 class Send {
42 public:
43 Send(fs::path config_path, char const* service);
45 void set_sender(Domain sender) { sender_ = sender; }
47 bool mail_from_rcpt_to(DNS::Resolver& res,
48 Mailbox const& from,
49 Mailbox const& to,
50 std::string& error_msg);
52 bool send(std::string_view msg);
54 void rset();
55 void quit();
57 private:
58 fs::path config_path_;
59 std::string service_;
61 Domain sender_;
63 std::unique_ptr<SMTP::Connection> conn_;
66 #endif // SEND_DOT_HPP