// file : libbutl/sendmail.ixx -*- C++ -*- // copyright : Copyright (c) 2014-2019 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. { template inline sendmail:: sendmail (E&& err, const std::string& from, const std::string& subj, const recipients_type& to, const recipients_type& cc, const recipients_type& bcc, O&&... options) : sendmail ([] (const char* [], std::size_t) {}, std::forward (err), from, subj, to, cc, bcc, std::forward (options)...) { } template inline sendmail:: sendmail (E&& err, const std::string& from, const std::string& subj, const recipients_type& to, const recipients_type& cc) : sendmail (err, from, subj, to, cc, recipients_type ()) { } template inline sendmail:: sendmail (E&& err, const std::string& from, const std::string& subj, const recipients_type& to) : sendmail (err, from, subj, to, recipients_type ()) { } template inline sendmail:: sendmail (const C& cmdc, E&& err, const std::string& from, const std::string& subj, const recipients_type& to, const recipients_type& cc, const recipients_type& bcc, O&&... options) { fdpipe pipe (fdopen_pipe ()); // Text mode seems appropriate. process& p (*this); p = process_start_callback (cmdc, pipe, 2, // No output expected so redirect to stderr. std::forward (err), "sendmail", "-i", // Don't treat '.' as the end of input. "-t", // Read recipients from headers. std::forward (options)...); // Close the reading end of the pipe not to block on writing if sendmail // terminates before that. // pipe.in.close (); out.open (std::move (pipe.out)); // Write headers. // // Note that if this throws, then the ofdstream will be closed first // (which should signal to the process we are done). Then the process's // destructor will wait for its termination ignoring any errors. // headers (from, subj, to, cc, bcc); } template inline sendmail:: sendmail (const C& cmdc, E&& err, const std::string& from, const std::string& subj, const recipients_type& to, const recipients_type& cc) : sendmail (cmdc, err, from, subj, to, cc, recipients_type ()) { } template inline sendmail:: sendmail (const C& cmdc, E&& err, const std::string& from, const std::string& subj, const recipients_type& to) : sendmail (cmdc, err, from, subj, to, recipients_type ()) { } }