summaryrefslogtreecommitdiff
path: root/src/lib/email.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-01-07 16:59:20 +0100
committerCarl Hetherington <cth@carlh.net>2025-01-09 20:56:26 +0100
commitb5a77af2453dc6073af7f5863413696b7b5d63d8 (patch)
tree475c0f7f25c1861993915bd18e2fd83080e41315 /src/lib/email.cc
parent32ac98a4b6f53f06cfe26687d338dfa5125ec20d (diff)
Use rfc_2822_date for email headers to make them compliant (#2928).
Diffstat (limited to 'src/lib/email.cc')
-rw-r--r--src/lib/email.cc14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/lib/email.cc b/src/lib/email.cc
index 7a6e58d91..028624c69 100644
--- a/src/lib/email.cc
+++ b/src/lib/email.cc
@@ -23,10 +23,10 @@
#include "config.h"
#include "email.h"
#include "exceptions.h"
+#include "util.h"
#include "variant.h"
#include <curl/curl.h>
#include <boost/algorithm/string.hpp>
-#include <boost/date_time/c_local_time_adjustor.hpp>
#include "i18n.h"
@@ -112,17 +112,7 @@ Email::get_data(void* ptr, size_t size, size_t nmemb)
void
Email::send(string server, int port, EmailProtocol protocol, string user, string password)
{
- char date_buffer[128];
- time_t now = time (0);
- strftime (date_buffer, sizeof(date_buffer), "%a, %d %b %Y %H:%M:%S ", localtime(&now));
-
- auto const utc_now = boost::posix_time::second_clock::universal_time ();
- auto const local_now = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local (utc_now);
- auto offset = local_now - utc_now;
- auto end = date_buffer + strlen(date_buffer);
- snprintf(end, sizeof(date_buffer) - (end - date_buffer), "%s%02d%02d", (offset.hours() >= 0 ? "+" : "-"), int(abs(offset.hours())), int(offset.minutes()));
-
- _email = "Date: " + string(date_buffer) + "\r\n"
+ _email = "Date: " + rfc_2822_date(time(nullptr)) + "\r\n"
"To: " + address_list (_to) + "\r\n"
"From: " + _from + "\r\n";