gs fan
/
GSwifi_smtp
SMTP client (send mail) GSwifi see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
Revision 2:6e611bfcd173, committed 2013-02-26
- Comitter:
- gsfan
- Date:
- Tue Feb 26 07:40:40 2013 +0000
- Parent:
- 1:8a46a714f75d
- Commit message:
- fix
Changed in this revision
GSwifi.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/GSwifi.lib Thu Nov 01 03:02:22 2012 +0000 +++ b/GSwifi.lib Tue Feb 26 07:40:40 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/gsfan/code/GSwifi/#4b97804c37d1 +http://mbed.org/users/gsfan/code/GSwifi/#e19538c1f13d
--- a/main.cpp Thu Nov 01 03:02:22 2012 +0000 +++ b/main.cpp Tue Feb 26 07:40:40 2013 +0000 @@ -2,7 +2,7 @@ #include "GSwifi.h" #define SERVER "mail.example.com" -#define PORT 587 // 25 +#define PORT 587 // or 25 #define TO "to@example.com" #define FROM "from@example.com" #define SUBJECT "TEST" @@ -10,12 +10,12 @@ #define USER "username" // SMTP Auth #define PWD "password" // SMTP Auth -#define SECURE GSSEC_WPA_PSK +#define SECURE GSwifi::GSSEC_WPA_PSK #define SSID "SSID" -#define PASS "passkey" +#define PASS "PASSPHRASE" -GSwifi gs(p13, p14); // TX, RX (no flow control) -// GSwifi gs(p13, p14, p12, P0_22); // TX, RX, CTS, RTS +GSwifi gs(p13, p14, p20); // TX, RX, Reset (no flow control) +//GSwifi gs(p13, p14, p12, P0_22, p20, NC, 115200); // TX, RX, CTS, RTS, Reset, Alarm Serial pc(USBTX, USBRX); DigitalOut led1(LED1), led2(LED2); @@ -23,11 +23,12 @@ int main () { IpAddr ipaddr, netmask, gateway, nameserver; Host host; + int r; led1 = 1; pc.baud(115200); - pc.printf("connect\r\n"); + pc.printf("connecting...\r\n"); if (gs.connect(SECURE, SSID, PASS)) { return -1; } @@ -38,8 +39,13 @@ 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 +// r = gs.mail(host, TO, FROM, SUBJECT, MESG); // no auth + r = gs.mail(host, TO, FROM, SUBJECT, MESG, USER, PWD); // SMTP auth + if (r == 0) { + pc.printf("sent\r\n"); + } else { + pc.printf("error\r\n"); + } for (;;) { gs.poll();