blob: cd6ddff3b5d67f446708a9049483f8ffce700de2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// file : libbutl/sendmail.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#ifndef __cpp_modules
#include <libbutl/sendmail.mxx>
#endif
// C includes.
#ifndef __cpp_lib_modules
#include <string>
#endif
// Other includes.
#ifdef __cpp_modules
module butl.sendmail;
// Only imports additional to interface.
#ifdef __clang__
#ifdef __cpp_lib_modules
import std.core;
#endif
import butl.process;
import butl.fdstream;
import butl.small_vector;
#endif
#endif
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.
}
}
|