EthernetInterface Libraryを使ったSimpleな SMTP ClientLibraryです. LOGIN認証を追加しました.(2014.4 Update) It is SMTPClient Library which is Simple using EthernetInterface Library.
Dependents: SimpleSMTPClient_HelloWorld USBHost-MSD_Sensors_1 IOT-GPS-SMS IOT_HW_5_websockets ... more
Diff: SimpleSMTPClient.cpp
- Revision:
- 7:0847fa2294a0
- Parent:
- 6:f6efc3cc8d13
- Child:
- 8:311b1f7cebb7
diff -r f6efc3cc8d13 -r 0847fa2294a0 SimpleSMTPClient.cpp --- a/SimpleSMTPClient.cpp Wed Dec 19 02:44:59 2012 +0000 +++ b/SimpleSMTPClient.cpp Sun Apr 13 07:39:38 2014 +0000 @@ -103,7 +103,7 @@ if ( auth == SMTP_AUTH_PLAIN ){ if ( user && pwd ) { - // SMTP auth + // SMTP auth PLAIN char tmp[80], buf[100]; int len; snprintf(tmp, sizeof(tmp), "%s%c%s%c%s",user, 0, user, 0, pwd); @@ -120,15 +120,46 @@ smtp.close(); } } + }else if ( auth == SMTP_AUTH_LOGIN) { + if ( user && pwd ) { + // SMTP auth + char tmp[80], buf[100]; + int len; + + smtp.send("AUTH LOGIN ", 11); + smtp.send("\r\n", 2); + + snprintf(tmp, sizeof(tmp), "%s",user); + len = strlen(user) ; + base64enc(tmp, len, buf, sizeof(buf)); + smtp.send(buf, strlen(buf)); + smtp.send("\r\n", 2); + + snprintf(tmp, sizeof(tmp), "%s",pwd); + len = strlen(pwd) ; + base64enc(tmp, len, buf, sizeof(buf)); + smtp.send(buf, strlen(buf)); + smtp.send("\r\n", 2); + + #ifdef __DEBUG__ + DBG("base64[%s]\r\n", buf); + #endif + if (receiveMessage(235)){ + smtp.send("QUIT\r\n", 6); + smtp.close(); + } + } } - smtp.send("MAIL FROM: <", 12); + smtp.send("MAIL FROM:<", 11); smtp.send(getFromAddress(), strlen(getFromAddress())); smtp.send(">\r\n", 3); if (receiveMessage(250)) { smtp.close(); return -1; } + + char tmp[128],addr[128]; int i = 0; strcpy(tmp,getToAddress());