MCPcopy Create free account
hub / github.com/acl-dev/acl / save_alternative

Method save_alternative

lib_acl_cpp/src/smtp/mail_body.cpp:213–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213bool mail_body::save_alternative(const char* html, size_t hlen,
214 const char* plain, size_t plen, string& out) const
215{
216 if (!html || !hlen || !plain || !plen) {
217 logger_error("invalid input!");
218 return false;
219 }
220
221 mail_message::create_boundary("0003",
222 const_cast<mail_body*>(this)->boundary_);
223 string ctype;
224 ctype.format("multipart/alternative;\r\n"
225 "\tboundary=\"%s\"", boundary_.c_str());
226 const_cast<mail_body*>(this)->set_content_type(ctype);
227
228 out.format_append("Content-Type: %s\r\n\r\n", content_type_.c_str());
229 out.format_append("--%s\r\n", boundary_.c_str());
230 if (!build_plain(plain, plen, charset_.c_str(), out)) {
231 return false;
232 }
233 out.append("\r\n\r\n");
234
235 out.format_append("--%s\r\n", boundary_.c_str());
236 if (!build_html(html, hlen, charset_.c_str(), out)) {
237 return false;
238 }
239 out.append("\r\n\r\n");
240
241 out.format_append("--%s--\r\n", boundary_.c_str());
242 return true;
243}
244
245} // namespace acl
246

Callers 1

save_relativeMethod · 0.80

Calls 6

build_plainFunction · 0.85
build_htmlFunction · 0.85
set_content_typeMethod · 0.80
formatMethod · 0.45
c_strMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected