configurable additional header for the voicemail template. Thanks Christophe Irles

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@86 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 20 years ago
parent 5dd98fd94a
commit 649e74aad8

@ -40,9 +40,17 @@ Email template format:
to: <destination email address>
from: <source email address>
subject: <subject line>
[empty line]
[header: <additional header>]
<empty line>
<body>
The optional header line adds a freely configurable
header to the mail. For example, the voicemail can be
securely filtered for the header X-Content if the following
is used in the voicemail template:
header: X-Content: Voicemail
This line is optional.
Variables:
----------

@ -38,8 +38,9 @@
AmMail::AmMail(const string& _from, const string& _subject,
const string& _to, const string& _body)
: from(_from), subject(_subject), body(_body),
const string& _to, const string& _body,
const string& _header)
: from(_from), subject(_subject), body(_body), header(_header),
to(_to), clean_up(0), error_count(0)
{
}

@ -80,6 +80,7 @@ public:
string subject;
string body;
string to;
string header;
/** Char set */
string charset;
@ -92,7 +93,8 @@ public:
int error_count;
AmMail(const string& _from, const string& _subject,
const string& _to, const string& _body = "");
const string& _to, const string& _body = "",
const string& _header = "");
~AmMail();
};

@ -108,6 +108,8 @@ bool AmSmtpClient::send(const AmMail& mail)
string rcpt_to = "rcpt to: <" + mail.to + ">";
vector<string> headers;
if (!mail.header.empty()) headers.push_back(mail.header);
headers.push_back("From: " + mail.from);
headers.push_back("To: " + mail.to);
headers.push_back("Subject: " + mail.subject);

@ -72,6 +72,7 @@ int EmailTemplate::load(const string& filename)
#define P_SUBJECT 1
#define P_TO 2
#define P_FROM 3
#define P_HEADER 4
int EmailTemplate::parse(char* buffer)
{
@ -103,6 +104,9 @@ int EmailTemplate::parse(char* buffer)
else if(!strncmp(begin,"from",4)){
state = P_FROM;
}
else if(!strncmp(begin,"header",4)){
state = P_HEADER;
}
else
state = 0;
@ -125,6 +129,9 @@ int EmailTemplate::parse(char* buffer)
case P_FROM:
from = begin;
break;
case P_HEADER:
header = begin;
break;
}
begin = ++s;
}
@ -149,7 +156,6 @@ int EmailTemplate::parse(char* buffer)
ERROR("EmailTemplate: invalid template: empty body\n");
return -1;
}
return 0;
}
@ -227,7 +233,8 @@ AmMail EmailTemplate::getEmail(const EmailTmplDict& dict) const
return AmMail(replaceVars(from,dict),
replaceVars(subject,dict),
replaceVars(to,dict),
replaceVars(body,dict));
replaceVars(body,dict),
replaceVars(header,dict));
}
catch(const string& err){
throw string("EmailTemplate: error in template '" + tmpl_file + "': " + err);

@ -46,6 +46,7 @@ class EmailTemplate
string to;
string from;
string body;
string header;
int parse(char* buffer);
string replaceVars(const string& str,const EmailTmplDict& dict) const;

Loading…
Cancel
Save