summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-21 23:14:56 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-21 23:14:56 +0100
commitceb0456d3dd141ec9ac4ddb99f42b0df390d1c6e (patch)
tree6096148cea47cab4992eca48aa3afce6d6e1da84 /src
parent92984df6ab50ba4ec90d105e44b58efa863c4b59 (diff)
Line-break base64 attachments with \r\n rather than just \n
to stop "line too long" errors with some email servers.
Diffstat (limited to 'src')
-rw-r--r--src/lib/emailer.cc15
-rw-r--r--src/lib/emailer.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/src/lib/emailer.cc b/src/lib/emailer.cc
index 534856ba6..ceb26caf6 100644
--- a/src/lib/emailer.cc
+++ b/src/lib/emailer.cc
@@ -41,11 +41,18 @@ Emailer::Emailer (string from, list<string> to, string subject, string body)
: _from (from)
, _to (to)
, _subject (subject)
- , _body (body)
+ , _body (fix (body))
, _offset (0)
{
- boost::algorithm::replace_all (_body, "\n", "\r\n");
- boost::algorithm::replace_all (_body, "\0", " ");
+
+}
+
+string
+Emailer::fix (string s) const
+{
+ boost::algorithm::replace_all (s, "\n", "\r\n");
+ boost::algorithm::replace_all (s, "\0", " ");
+ return s;
}
void
@@ -154,7 +161,7 @@ Emailer::send (string server, int port, string user, string password)
char* out;
long int bytes = BIO_get_mem_data (bio, &out);
- _email += string (out, bytes);
+ _email += fix (string (out, bytes));
BIO_free_all (b64);
}
diff --git a/src/lib/emailer.h b/src/lib/emailer.h
index 7a614019e..0309b134d 100644
--- a/src/lib/emailer.h
+++ b/src/lib/emailer.h
@@ -48,6 +48,8 @@ public:
private:
+ std::string fix (std::string s) const;
+
std::string _from;
std::list<std::string> _to;
std::string _subject;