#include <curl/curl.h>
#include <boost/algorithm/string.hpp>
#include <boost/date_time/c_local_time_adjustor.hpp>
-#include <boost/foreach.hpp>
#include "i18n.h"
using std::list;
using std::cout;
using std::pair;
-using boost::shared_ptr;
-using dcp::Data;
+using std::shared_ptr;
+using dcp::ArrayData;
Emailer::Emailer (string from, list<string> to, string subject, string body)
: _from (from)
_email += _body;
- BOOST_FOREACH (Attachment i, _attachments) {
+ for (auto i: _attachments) {
_email += "\r\n\r\n--" + boundary + "\r\n"
"Content-Type: " + i.mime_type + "; name=" + i.name + "\r\n"
"Content-Transfer-Encoding: Base64\r\n"
BIO* bio = BIO_new (BIO_s_mem());
bio = BIO_push (b64, bio);
- Data data (i.file);
- BIO_write (bio, data.data().get(), data.size());
+ ArrayData data (i.file);
+ BIO_write (bio, data.data(), data.size());
(void) BIO_flush (bio);
char* out;
throw NetworkError ("Could not initialise libcurl");
}
- if ((protocol == EMAIL_PROTOCOL_AUTO && port == 465) || protocol == EMAIL_PROTOCOL_SSL) {
+ if ((protocol == EmailProtocol::AUTO && port == 465) || protocol == EmailProtocol::SSL) {
/* "SSL" or "Implicit TLS"; I think curl wants us to use smtps here */
curl_easy_setopt (curl, CURLOPT_URL, String::compose("smtps://%1:%2", server, port).c_str());
} else {
curl_easy_setopt (curl, CURLOPT_MAIL_FROM, _from.c_str());
struct curl_slist* recipients = 0;
- BOOST_FOREACH (string i, _to) {
+ for (auto i: _to) {
recipients = curl_slist_append (recipients, i.c_str());
}
- BOOST_FOREACH (string i, _cc) {
+ for (auto i: _cc) {
recipients = curl_slist_append (recipients, i.c_str());
}
- BOOST_FOREACH (string i, _bcc) {
+ for (auto i: _bcc) {
recipients = curl_slist_append (recipients, i.c_str());
}
curl_easy_setopt (curl, CURLOPT_READDATA, this);
curl_easy_setopt (curl, CURLOPT_UPLOAD, 1L);
- if (protocol == EMAIL_PROTOCOL_AUTO || protocol == EMAIL_PROTOCOL_STARTTLS) {
+ if (protocol == EmailProtocol::AUTO || protocol == EmailProtocol::STARTTLS) {
curl_easy_setopt (curl, CURLOPT_USE_SSL, (long) CURLUSESSL_TRY);
}
curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L);
Emailer::address_list (list<string> addresses)
{
string o;
- BOOST_FOREACH (string i, addresses) {
+ for (auto i: addresses) {
o += i + ", ";
}