| 167 | } |
| 168 | |
| 169 | bool mail_body::save_relative(const char* html, size_t hlen, |
| 170 | const char* plain, size_t plen, |
| 171 | const std::vector<mail_attach*>& attachments, |
| 172 | string& out) const |
| 173 | { |
| 174 | if (!html || !hlen || !plain || !plen || attachments.empty()) { |
| 175 | logger_error("invalid input!"); |
| 176 | return false; |
| 177 | } |
| 178 | |
| 179 | mail_message::create_boundary("0002", |
| 180 | const_cast<mail_body*>(this)->boundary_); |
| 181 | string ctype; |
| 182 | ctype.format("multipart/relative;\r\n" |
| 183 | "\ttype=\"multipart/alternative\";\r\n" |
| 184 | "\tboundary=\"%s\"", boundary_.c_str()); |
| 185 | const_cast<mail_body*>(this)->set_content_type(ctype); |
| 186 | |
| 187 | out.format_append("Content-Type: %s\r\n\r\n", content_type_.c_str()); |
| 188 | out.append("\r\n"); |
| 189 | out.format_append("--%s\r\n", boundary_.c_str()); |
| 190 | |
| 191 | // �ݹ�һ�㣬�������� alternative ��ʽ���� |
| 192 | mail_body body(charset_.c_str(), transfer_encoding_.c_str()); |
| 193 | bool ret = body.save_alternative(html, hlen, plain, plen, out); |
| 194 | if (ret == false) { |
| 195 | return ret; |
| 196 | } |
| 197 | |
| 198 | out.append("\r\n"); |
| 199 | |
| 200 | std::vector<mail_attach*>::const_iterator cit; |
| 201 | for (cit = attachments.begin(); cit != attachments.end(); ++cit) { |
| 202 | out.format_append("--%s\r\n", boundary_.c_str()); |
| 203 | if (!(*cit)->save_to(coder_, out)) { |
| 204 | return false; |
| 205 | } |
| 206 | out.append("\r\n"); |
| 207 | } |
| 208 | |
| 209 | out.format_append("\r\n--%s--\r\n", boundary_.c_str()); |
| 210 | return true; |
| 211 | } |
| 212 | |
| 213 | bool mail_body::save_alternative(const char* html, size_t hlen, |
| 214 | const char* plain, size_t plen, string& out) const |
nothing calls this directly
no test coverage detected