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

Method save_relative

lib_acl_cpp/src/smtp/mail_body.cpp:169–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169bool 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
213bool mail_body::save_alternative(const char* html, size_t hlen,
214 const char* plain, size_t plen, string& out) const

Callers

nothing calls this directly

Calls 9

set_content_typeMethod · 0.80
save_alternativeMethod · 0.80
beginMethod · 0.80
emptyMethod · 0.45
formatMethod · 0.45
c_strMethod · 0.45
appendMethod · 0.45
endMethod · 0.45
save_toMethod · 0.45

Tested by

no test coverage detected