From 61377c582e0f2675baa5f5e6e30a35d1a4164b33 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 1 May 2017 16:08:43 +0300 Subject: Add hxx extension for headers and lib prefix for library dir --- libbutl/sendmail.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libbutl/sendmail.cxx (limited to 'libbutl/sendmail.cxx') diff --git a/libbutl/sendmail.cxx b/libbutl/sendmail.cxx new file mode 100644 index 0000000..5b1c863 --- /dev/null +++ b/libbutl/sendmail.cxx @@ -0,0 +1,40 @@ +// file : libbutl/sendmail.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +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. + } +} -- cgit v1.1