| 476 | } |
| 477 | |
| 478 | bool mail_message::save_to(const char* filepath) |
| 479 | { |
| 480 | ofstream fp; |
| 481 | if (!fp.open_write(filepath)) { |
| 482 | logger_error("open %s error: %s", filepath, last_serror()); |
| 483 | return false; |
| 484 | } |
| 485 | |
| 486 | filepath_ = dbuf_->dbuf_strdup(filepath); |
| 487 | |
| 488 | // �������ʼ�ͷ�����������ļ����� |
| 489 | |
| 490 | if (!append_header(fp)) { |
| 491 | return false; |
| 492 | } |
| 493 | |
| 494 | // ����� multipart ��ʽ���� multipart ����������ļ����� |
| 495 | |
| 496 | if (!attachments_.empty()) { |
| 497 | return append_multipart(fp); |
| 498 | } |
| 499 | |
| 500 | if (body_ == NULL) { |
| 501 | logger_error("body null!"); |
| 502 | return false; |
| 503 | } |
| 504 | |
| 505 | // �Է� multipart ��ʽ��ֱ�ӽ���������������ļ����� |
| 506 | |
| 507 | string buf(8192); |
| 508 | if (!body_->save_to(buf)) { |
| 509 | return false; |
| 510 | } |
| 511 | |
| 512 | if (fp.write(buf) == -1) { |
| 513 | logger_error("write to %s error %s", |
| 514 | fp.file_path(), last_serror()); |
| 515 | return false; |
| 516 | } |
| 517 | |
| 518 | return true; |
| 519 | } |
| 520 | |
| 521 | } // namespace acl |
| 522 |
no test coverage detected