EthernetInterface Libraryを使ったSimpleな SMTP Clientプログラムを作成してみました。 I made the SMTP Client program that was Simple using EthernetInterface Library.

Dependencies:   EthernetInterface NTPClient SimpleSMTPClient TextLCD mbed-rtos mbed

Fork of SimpleSMTPClient_HelloWorld by Tadao Iida

Simple SMTP Client

Used EthernetInterface Library
Don't support TSL/SSL.

Import librarySimpleSMTPClient

EthernetInterface Libraryを使ったSimpleな SMTP ClientLibraryです. LOGIN認証を追加しました.(2014.4 Update) It is SMTPClient Library which is Simple using EthernetInterface Library.

Import programSimpleSMTPClient_HelloWorld

EthernetInterface Libraryを使ったSimpleな SMTP Clientプログラムを作成してみました。 I made the SMTP Client program that was Simple using EthernetInterface Library.

Files at this revision

API Documentation at this revision

Comitter:
sunifu
Date:
Mon Dec 03 09:34:15 2012 +0000
Child:
1:24f200936579
Commit message:
Ver1.0

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
NTPClient.lib Show annotated file Show diff for this revision Revisions of this file
SimpleSMTPClient.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.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
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Mon Dec 03 09:34:15 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTPClient.lib	Mon Dec 03 09:34:15 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NTPClient/#881559865a93
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SimpleSMTPClient.lib	Mon Dec 03 09:34:15 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/sunifu/code/SimpleSMTPClient/#f440cf84cfea
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Mon Dec 03 09:34:15 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 03 09:34:15 2012 +0000
@@ -0,0 +1,72 @@
+// -- 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 SERVER "smtp.mailserver.domain"
+#define PORT "587" //25 or 587(OutBound Port25 Blocking )
+#define USER "user-id"
+#define PWD "password"
+#define FROM_ADDRESS "from-user@domain"
+// 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 "to-user@domain" 
+
+#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");
+
+    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);
+
+    // IP Address 
+    printf("IP Address is %s\n", eth.getIPAddress());
+    lcd.locate(0,1);
+    lcd.printf("%s", eth.getIPAddress());
+
+    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, PORT,SMTP_AUTH_PLAIN);
+ 
+    if (ret) {
+        printf("E-mail Transmission Error\r\n");
+    } else {
+        printf("E-mail Transmission OK\r\n");
+    }
+ 
+    return 0;
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Dec 03 09:34:15 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#88a1a9c26ae3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 03 09:34:15 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b60934f96c0c
\ No newline at end of file