17 static uint16 client_port = 2000;
30 static void MakeMIME(uint8 *MIME, uint8 *sender, uint8 *recipient, uint8 *subject, uint8 *content)
32 sprintf((
void *)MIME,
"From: %s\r\n"\
37 , sender, recipient, subject, content);
48 static void send_receive(uint8 s, uint8 * data, uint8 * pSip)
52 DBGA(
"Send------>%s", data);
54 n = sprintf((
char*)buf,
"%s\r\n", data);
55 while(
TCPSend(s, (
void *)buf, n) <= 0);
58 while((n =
TCPRecv(s, (
void *)buf, 255)) <= 0);
61 DBGA(
"Receive------>%s", buf);
79 int8
send_mail(uint8 s, uint8 *sender, uint8 *passwd,
80 uint8 *recipient, uint8 *subject, uint8 *content, uint8 *pSip)
83 uint8 MIME[256]={
'\0'}, encode[16]={
'\0'};
89 while((n =
TCPRecv(s, (
void *)buf, 255)) <= 0);
91 DBGA(
"Receive(%d)------>%s", n, buf);
92 if(strncmp((
char*)buf,
"220", 3)) {
93 ERR(
"This is not SMTP Server");
97 send_receive(s,
"HELO", pSip);
98 if(strncmp((
char*)buf,
"250", 3)) {
103 send_receive(s,
"AUTH LOGIN", pSip);
104 if(strncmp((
char*)buf,
"334", 3)) {
105 ERR(
"Fail AUTH LOGIN");
109 base64_encode((
void *)sender, strlen((
void *)sender)+1, (
void *)encode);
110 send_receive(s, encode, pSip);
111 if(strncmp((
char*)buf,
"334", 3)) {
116 base64_encode((
void *)passwd, strlen((
void *)passwd)+1, (
void *)encode);
117 send_receive(s, encode, pSip);
118 if(strncmp((
char*)buf,
"235", 3)) {
123 sprintf((
char*)buf,
"MAIL FROM:%s", sender);
124 send_receive(s, (
void *)buf, pSip);
125 if(strncmp((
char*)buf,
"250", 3)) {
126 ERR(
"Fail MAIL FROM");
131 sprintf((
char*)buf,
"RCPT TO:%s", recipient);
132 send_receive(s, (
void *)buf, pSip);
133 if(strncmp((
char*)buf,
"250", 3)) {
138 send_receive(s,
"DATA", pSip);
139 if(strncmp((
char*)buf,
"354", 3)) {
144 MakeMIME(MIME, sender, recipient, subject, content);
145 send_receive(s, MIME, pSip);
146 if(strncmp((
char*)buf,
"250", 3)) {
147 ERR(
"Fail Send Content");
151 send_receive(s,
"QUIT", pSip);
160 ERR(
"connection error");
165 while(getSn_SR(s) != SOCK_CLOSED);