Simple message
To create a plain text message one must set the sender, recipient, subject and content:
#include <cstdlib>
#include <mailio/message.hpp>
using mailio::message;
int main()
{
message msg;
msg.from(mail_address("mail io", "address@mailio.dev"));
msg.add_recipient(mail_address("mail io", "address@mailio.dev"));
msg.subject("Zdravo, Svete!");
msg.content("Hello, World!");
return EXIT_SUCCESS;
}
By default, the message date/time is set to the current date and 00:00 time. To modify it, set the appropriate header:
ptime t = time_from_string("2014-01-17 13:09:22");
time_zone_ptr tz(new posix_time_zone("-07:30"));
local_date_time ldt(t, tz);
msg.date_time(ldt);
If the message date is invalid, missing or too far in the past, an email server can set the date to the present or even discard the message.