1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
/*
* Copyright (C) 2011 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include <iostream>
#include <fstream>
#include <boost/test/unit_test.hpp>
#include <Wt/Mail/Client>
#include <Wt/Mail/Message>
#include <Wt/WLocalDateTime>
using namespace Wt;
using namespace Wt::Mail;
BOOST_AUTO_TEST_CASE( mail_test1 )
{
Message m;
m.setFrom(Mailbox("bas@kode.be", "Bas Deforche"));
m.addRecipient(To, Mailbox("koen@emweb.be", "Koen Deforche"));
m.addRecipient(Bcc,
Mailbox("koen.deforche@gmail.com",
WString::fromUTF8("Koen Deforche")));
m.setSubject(WString::fromUTF8("Hey there, \xe2\x82\xac !"));
m.setBody(WString::fromUTF8
("Body here \xe2\x82\xac\n"
"We have been working hard\n"
".beware this\n"
"And long lines should be properly split using a soft line end,"
"let's see how that turns out.\n"
"But a space before a new line needs some special handling. \n"
"Are we good?"));
m.addHtmlBody(WString::fromUTF8
("<div>"
"<h1>HTML body here</h1>"
"Long lines should be properly split using a soft line "
"end, let's see how that turns out.<br>"
"This is necessary to make lots of \xe2\x82\xac! "
"Please visit <a href=\"http://www.emweb.be\">Emweb</a>."
"</div>"));
#if 0
Client c;
c.connect("localhost");
c.send(m);
#else
m.write(std::cout);
#endif
}
BOOST_AUTO_TEST_CASE( mail_test2 )
{
Message m;
m.setFrom(Mailbox("bas@kode.be", "Bas Deforche"));
m.setDate(WLocalDateTime::currentServerDateTime());
m.addRecipient(To, Mailbox("koen@emweb.be", "Koen Deforche"));
m.addRecipient(Bcc,
Mailbox("koen.deforche@gmail.com",
WString::fromUTF8("Koen Deforche")));
m.setSubject(WString::fromUTF8("Hey there, \xe2\x82\xac !"));
m.setBody(WString::fromUTF8
("Body here \xe2\x82\xac\n"
"We have been working hard\n"
".beware this\n"
"And long lines should be properly split using a soft line end,"
"let's see how that turns out."));
m.addHtmlBody(WString::fromUTF8
("<div>"
"<h1>HTML body here</h1>"
"Long lines should be properly split using a soft line "
"end, let's see how that turns out.<br>"
"This is necessary to make lots of \xe2\x82\xac! "
"Please visit <a href=\"http://www.emweb.be\">Emweb</a>."
"</div>"));
std::ifstream pdf("test.pdf");
m.addAttachment("application/pdf", "hello.pdf", &pdf);
#if 0
Client c;
c.connect("localhost");
c.send(m);
#else
m.write(std::cout);
#endif
}
|