| 211 | } |
| 212 | |
| 213 | bool 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 |
no test coverage detected