aboutsummaryrefslogtreecommitdiff
path: root/butl/sendmail.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-13 10:47:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-13 10:47:47 +0200
commitabbb859d9eefa62a5cc774bd08020bf30ad77c26 (patch)
treeac2b8648dc9d792154680bff38e5c3f1be73264d /butl/sendmail.cxx
parent714ce38164dbb4b19be8db286182dba3784d471f (diff)
Implement sendmail process
Diffstat (limited to 'butl/sendmail.cxx')
-rw-r--r--butl/sendmail.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/butl/sendmail.cxx b/butl/sendmail.cxx
new file mode 100644
index 0000000..103bab5
--- /dev/null
+++ b/butl/sendmail.cxx
@@ -0,0 +1,40 @@
+// file : butl/sendmail.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <butl/sendmail>
+
+using namespace std;
+
+namespace butl
+{
+ void sendmail::
+ headers (const std::string& from,
+ const std::string& subj,
+ const recipients_type& to,
+ const recipients_type& cc,
+ const recipients_type& bcc)
+ {
+ if (!from.empty ())
+ out << "From: " << from << endl;
+
+ auto rcp =[this] (const char* h, const recipients_type& rs)
+ {
+ if (!rs.empty ())
+ {
+ bool f (true);
+ out << h << ": ";
+ for (const string& r: rs)
+ out << (f ? (f = false, "") : ", ") << r;
+ out << endl;
+ }
+ };
+
+ rcp ("To", to);
+ rcp ("Cc", cc);
+ rcp ("Bcc", bcc);
+
+ out << "Subject: " << subj << endl
+ << endl; // Header/body separator.
+ }
+}