| 6 | static acl::polarssl_conf ssl_conf; |
| 7 | |
| 8 | static bool send_mail(const char* addr, const char* sender, const char* pass, |
| 9 | const char* recipients, bool use_ssl) |
| 10 | { |
| 11 | acl::mail_message message("gbk"); |
| 12 | message.set_auth(sender, pass) |
| 13 | .set_from(sender) |
| 14 | .add_recipients(recipients); |
| 15 | |
| 16 | acl::smtp_client conn(addr, 60, 60); |
| 17 | |
| 18 | // �����Ƿ���� SSL ͨ�ŷ�ʽ |
| 19 | if (use_ssl) |
| 20 | conn.set_ssl(&ssl_conf); |
| 21 | |
| 22 | // �����ŷ� |
| 23 | if (conn.send_envelope(message) == false) |
| 24 | { |
| 25 | printf("send envelope error: %d, %s\r\n", |
| 26 | conn.get_code(), conn.get_status()); |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | // ��ʼ�����ʼ������� |
| 31 | if (conn.data_begin() == false) |
| 32 | { |
| 33 | printf("send data begin error: %d, %s\r\n", |
| 34 | conn.get_code(), conn.get_status()); |
| 35 | } |
| 36 | |
| 37 | const char* data = "From: \"֣����1\" <zsxxsz@263.net>\r\n" |
| 38 | "To: \"֣����2\" <zsxxsz@263.net>\r\n" |
| 39 | "Subject: ���ã�hello, world!\r\n" |
| 40 | "\r\n" |
| 41 | "hello world!\r\n"; |
| 42 | |
| 43 | // �����ʼ������� |
| 44 | if (conn.write(data, strlen(data)) == false) |
| 45 | { |
| 46 | printf("send data error: %d, %s\r\n", |
| 47 | conn.get_code(), conn.get_status()); |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | // ������� |
| 52 | if (conn.data_end() == false) |
| 53 | { |
| 54 | printf("send data end error: %d, %s\r\n", |
| 55 | conn.get_code(), conn.get_status()); |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | printf("sendmail ok, from: %s, to: %s, code: %d, status: %s\r\n", |
| 60 | sender, recipients, conn.get_code(), |
| 61 | conn.get_status()); |
| 62 | |
| 63 | // ���� QUIT ���� |
| 64 | if (conn.quit() == false) |
| 65 | { |
no test coverage detected
searching dependent graphs…