![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
SMS WORKING
Dependencies: EthernetInterface NTPClient SimpleSMTPClient TextLCD mbed-rtos mbed
Fork of Application-SimpleSMTPClient_HelloWorld by
main.cpp
- Committer:
- bhakti08
- Date:
- 2014-04-29
- Revision:
- 5:758769bf30b8
- Parent:
- 4:89d1b1db4605
File content as of revision 5:758769bf30b8:
// -- SimpleSMTPClient_HelloWorld.cpp -- // Used EthernetInterface Library // Don't support TSL/SSL. #include "mbed.h" #include "EthernetInterface.h" #include "NTPClient.h" #include "SimpleSMTPClient.h" #include "TextLCD.h" #define DOMAIN "comcast.net" //gmail.com #define SERVER "smtp.comcast.net" //smtp.gmail.com #define PORT "587" //25 or 587,465(OutBound Port25 Blocking ) 465 #define USER "patkionkar" //bhakti.kulkarni08 #define PWD "book#jungle" //bhakti0887 #define FROM_ADDRESS "patkionkar@comcast.net" //bhakti.kulkarni08 // TO_ADDRESS (Of some address is possible.) // to-user1@domain, to-user2@domain, to-user3@domain .... // The TO_ADDRESS are less than 128 characters. #define TO_ADDRESS "patkionkar@comcast.net" #define SUBJECT "Test Mail" TextLCD lcd(p24, p26, p27, p28, p29, p30); int main() { EthernetInterface eth; char strTimeMsg[16]; lcd.cls(); printf("\n\n/* SimpleMTPClient library demonstration */\n"); printf("Setting up ...\n"); eth.init(); eth.connect(); printf("Connected OK\n"); // IP Address printf("IP Address is %s\n", eth.getIPAddress()); lcd.locate(0,1); lcd.printf("%s", eth.getIPAddress()); // NTP Client printf("NTP setTime...\n"); NTPClient ntp; ntp.setTime("pool.ntp.org"); time_t ctTime = time(NULL)+32400; // JST printf("\nTime is now (JST): %d %s\n", ctTime, ctime(&ctTime)); strftime(strTimeMsg,16,"%y/%m/%d %H:%M",localtime(&ctTime)); lcd.locate(0,0); lcd.printf("[%s]",strTimeMsg); SimpleSMTPClient smtp; int ret; char msg[]="Hello SimpleSMTPClient "; smtp.setFromAddress(FROM_ADDRESS); smtp.setToAddress(TO_ADDRESS); smtp.setMessage(SUBJECT,msg); smtp.addMessage("TEST TEST TEST\r\n"); ret = smtp.sendmail(SERVER, USER, PWD, DOMAIN,PORT,SMTP_AUTH_PLAIN); printf("return value: %d\r\n",ret); if (ret) { printf("E-mail Transmission Error\r\n"); } else { printf("E-mail Transmission OK\r\n"); } // // send as SMS text // smtp.setFromAddress(FROM_ADDRESS); smtp.setToAddress("4086851676@txt.att.net"); // MODIFY for carrier smtp.setMessage(SUBJECT,msg); smtp.addMessage("TEST TEST TEST\r\n"); ret = smtp.sendmail(SERVER, USER, PWD, DOMAIN,PORT,SMTP_AUTH_PLAIN); if (ret) { printf("SMS Transmission Error\r\n"); } else { printf("SMS Transmission OK\r\n"); } return 0; }