gs fan
/
GSwifi_smtp
SMTP client (send mail) GSwifi see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
main.cpp
- Committer:
- gsfan
- Date:
- 2012-11-01
- Revision:
- 1:8a46a714f75d
- Parent:
- 0:50f63fa8a396
- Child:
- 2:6e611bfcd173
File content as of revision 1:8a46a714f75d:
#include "mbed.h" #include "GSwifi.h" #define SERVER "mail.example.com" #define PORT 587 // 25 #define TO "to@example.com" #define FROM "from@example.com" #define SUBJECT "TEST" #define MESG "Hello!\r\n" #define USER "username" // SMTP Auth #define PWD "password" // SMTP Auth #define SECURE GSSEC_WPA_PSK #define SSID "SSID" #define PASS "passkey" GSwifi gs(p13, p14); // TX, RX (no flow control) // GSwifi gs(p13, p14, p12, P0_22); // TX, RX, CTS, RTS Serial pc(USBTX, USBRX); DigitalOut led1(LED1), led2(LED2); int main () { IpAddr ipaddr, netmask, gateway, nameserver; Host host; led1 = 1; pc.baud(115200); pc.printf("connect\r\n"); if (gs.connect(SECURE, SSID, PASS)) { return -1; } gs.getAddress(ipaddr, netmask, gateway, nameserver); pc.printf("ip %d.%d.%d.%d\r\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]); led2 = 1; pc.printf("sendmail\r\n"); host.setName(SERVER); host.setPort(PORT); // gs.mail(host, TO, FROM, SUBJECT, MESG); // no auth gs.mail(host, TO, FROM, SUBJECT, MESG, USER, PWD); // SMTP auth for (;;) { gs.poll(); wait_ms(50); led1 = !led1; led2 = 0; } }