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

Function send_mail

lib_acl_cpp/samples/smtp_client/main.cpp:8–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6static acl::polarssl_conf ssl_conf;
7
8static 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 {

Callers 1

mainFunction · 0.85

Calls 10

send_envelopeMethod · 0.80
get_codeMethod · 0.80
data_beginMethod · 0.80
data_endMethod · 0.80
set_sslMethod · 0.45
get_statusMethod · 0.45
writeMethod · 0.45
quitMethod · 0.45
sendMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…