00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 #ifndef MAIL_MAIL_H
00025 #define MAIL_MAIL_H
00026
00027
00028
00029 #include <string>
00030 #include <vector>
00031
00032 #include <misc/ratio.h>
00033
00034
00035
00037
00038 namespace mail
00039 {
00040
00041
00042
00043 class Transport;
00044
00045
00046
00048
00050 class Mail
00051 {
00052 public:
00053
00054 typedef std::vector<std::string> text_type;
00055
00056
00057
00059 enum
00060 {
00062 mfAuthenticated = 0x00000001,
00064 mfNoQuota = 0x00000002
00065 };
00066
00068 enum
00069 {
00071 meSuccess = 0x00000000,
00073 meIncomplete = 0x00000001,
00075 meQuota = 0x00000002,
00077 meDelivery = 0x0000004,
00079 meConfig = 0x00000008,
00081 meTemporary = 0x80000000
00082 };
00083
00084
00085
00087 static bool configured();
00088
00090
00102 static bool valid_address(char const *address, bool noplus);
00103
00105 Mail() : m_from_name(), m_from_address(), m_subject(), m_sender(),
00106 m_to_name(), m_to_address(), m_origin(), m_text(),
00107 m_data() { }
00109 Mail(Mail const &m) : m_from_name(m.m_from_name),
00110 m_from_address(m.m_from_address), m_subject(m.m_subject),
00111 m_sender(m.m_sender), m_to_name(m.m_to_name),
00112 m_to_address(m.m_to_address), m_origin(m.m_origin),
00113 m_text(m.m_text), m_data(m.m_data) { }
00115 Mail &operator=(Mail const &right);
00116
00118
00140 bool send(uint32_t flags, uint32_t *err = 0, std::string *errdesc = 0);
00141
00143 std::string const &from_name() const { return m_from_name; }
00145 std::string const &from_name(std::string const &from_name)
00146 { return (m_from_name = from_name); }
00147
00149 std::string const &from_address() const { return m_from_address; }
00151 std::string const &from_address(std::string const &from_address)
00152 { return (m_from_address = from_address); }
00153
00155 std::string const &subject() const { return m_subject; }
00157 std::string const &subject(std::string const &subject)
00158 { return (m_subject = subject); }
00159
00161 std::string const &sender() const { return m_sender; }
00163 std::string const &sender(std::string const &sender)
00164 { return (m_sender = sender); }
00165
00167 std::string const &to_name() const { return m_to_name; }
00169 std::string const &to_name(std::string const &to_name)
00170 { return (m_to_name = to_name); }
00171
00173 std::string const &to_address() const { return m_to_address; }
00175 std::string const &to_address(std::string const &to_address)
00176 { return (m_to_address = to_address); }
00177
00179 std::string const &origin() const { return m_origin; }
00181
00187 std::string const &origin(std::string const &origin)
00188 { return (m_origin = origin); }
00189
00191 text_type const &text() const { return m_text; }
00193
00200 text_type const &text_add(std::string const &line);
00202 text_type const &text_addf(char const *format, ...) FORMAT(printf, 2, 3);
00203
00205
00210 std::string const &data() const { return m_data; }
00211 private:
00212 std::string m_from_name;
00213 std::string m_from_address;
00214 std::string m_subject;
00215 std::string m_sender;
00216 std::string m_to_name;
00217 std::string m_to_address;
00218 std::string m_origin;
00219 text_type m_text;
00220 std::string m_data;
00221
00222 void generate_data();
00223
00224 void set_error(uint32_t *err, std::string *errdesc, uint32_t myerr,
00225 std::string const &mydesc) const;
00226 };
00227
00228
00229
00231 extern void conf_options(std::string const &sname, std::string const &saddress,
00232 misc::Ratio const &lauth, misc::Ratio const &lunauth,
00233 misc::Ratio const &slimit);
00234
00236 extern void conf_transport(Transport *transport);
00237
00238
00239
00240 }
00241
00242
00243
00244 #endif