Need help for sending an Email using SMTP

Hi. I’m kinda new to Arduino, so please explain simply for me! :roll_eyes:
I’ trying to use my Arduino to send some Emails, but actually, I’m getting my Arduino to send some serial signals, and on the computer, I get these signals and send an Email using Processing.
I have no problems with doing that, But the first thing I’m trying to do is to send it using command line!
I know we should use this: “telnet 465” the port used is for SSL protocol (port #25 doesn’t work for Gmail) But I get an empty black screen after running this!!
I tried using: “telnet 587” which uses TLS protocol, And I got the appropriate message, after running “helo” everything was fine but when I tried to specify the sender’s Email I got this message: “Must issue a STARTTLS command first!”
I did that and I executed this command: “STARTTLS” just that simple! I got the response: “Ready to start TLS”, but when I tried specifying the sender’s Email, after 11 characters typed, I got this message: “connection to host lost!” and it exits out! …
I looked for some troubleshoot and I found out that we need to Enable SSL and to make sure that allow authentication is Enabled on the smtp client. But I don’t know how to do these stuff! I’m trying to do this at localhost. Anyone can help??

I need some help here please! No one has ever sent an Email with Arduino?? I just need the SMTP configuration! Do I need to enable SSL or something?? Why do I see the empty blank window when I'm trying to use gmail smtp server using SSL???

You're getting a 'blank' screen because the gmail server is waiting for you to start an SSL connection. Telnet won't do that for you and an Arduino definitely can't handle SSL or TLS.

Alternative: Setup a PHP server or so that mails from a form. The Arduino can fill in a form.

Your problems may be with using the Gmail server. Does this server allow for direct connection from users? A standard ISP SMTP server is fairly easy to deal with.

Thank you all for your help. A PHP form uses SMTP server itself to send an Email. I just need to know "How can I use SSL through a command prompt?" That's all. I guess the best way to solve this is to use Arduino to send only serial messages, and then on the other side (PC) we can use another program (like Processing) to get those Serial messages, and then Email them, because Processing won't have those limits of Arduino and we can do this easily. OK now how are we supposed to do this?

I just need to know "How can I use SSL through a command prompt?" That's all.

Have you tried searching for command line email programs?

zoomkat: Have you tried searching for command line email programs?

This is what I found: I guess it's gonna work...

YAY! It worked!!! :smiley:
But wait… NOOOOO! :astonished:
I mean, it worked, but I have another problem now.
OK I’m going to explain from the beginning:
I downloaded “stunnel” which is a program that tunnels SSL and makes it work through command prompt.
I tried it myself and I was able to send an Email to my Gmail account using telnet:

telnet localhost 2301
Auth Login
my email in base64
my pass in base64
subject: WARNING!
this is the body of the email

This works in command prompt win XP x86 and I received the Email. But…
I’m trying to do the same using processing, and using the networking feature in it which is the same as Socket Programming (but much easier!) and I was able to connect, send and receive information using a Client() object in processing. I even receive response from Gmail smtp server but the problem is:
when I try to send the dot (".") which represents the end of DATA part, Gmail service doesn’t recongnize this command!
Everything else works fine, but when I send the dot, I don’t receive any response which means that Gmail service considers that character as a part of the body. Weird…!
I even tried using char(46) which returns the same character, but no use.
Any ideas?? :~

Is the body being seperated from the period with a carrage return/line feed?

Yes! The program enters the DATA, line-feed,then DOT, then line-feed. That's exactly how it is!

All of the commands are entered with a new-line characters - char(10) - at the end. I even tried using carriage-return after/before it, but it didn't make a difference.

Below is what works with an ethernet shield. The println should puting a carrage return and line feed at the end of each line.

client.println("Subject: You Have Mail!!"); /* insert subject */
client.println("Please let me know it worked!!!"); /* insert body */
client.println("."); /* end email */
client.println("QUIT"); /* terminate connection */

Hey. :open_mouth:

Have a look at these threads:

especially the last post in that thread. I have set up a little .php script like described, and using that to send emails from the arduino is very simple.

Hi. Thanks for the help, but I'm not using Arduino itself I'm using Processing for this purpose! And the client object doesn't have the println or print function in it, it uses only one function named "write", and that's all! I'm trying to do this the traditional way, I know how to do it using PHP web services. If someone tells me exactly what happens when I press the Enter button, I guess I can print the exact same characters using the write method, too. It's just that the service doesn't treat a dot + line-feed the same way as dot + Enter. Does anyone know the difference? Thank you for the help.

It's just that the service doesn't treat a dot + line-feed the same way as dot + Enter. Does anyone know the difference?

I think when you use the enter, a line feed and then a carrage return is sent. Check the arrow on your enter key.

Yeah! I did it! The only problem was that: the Enter button, or better say, this NewLine, has different meaning under different operation systems. For Windows and MS-DOS, it is 2 characters actually: carriage return + line feed! both of them together with ASCII 13 for carriage return and 10 for line feed, so after each command, I had to put one carriage return and one line feed, but I only did the line feed so it wasn't working. Anyway it's working now thank you all for the help :). Now I'm going to make it CALL my cell phone! I've heard that there are shields for this purpose, but I don't have complete instructions, like the code, the library, and how to manipulate my SIM card using that shield. The only instance I know for now is GSM sheild here: I made another topic for this purpose:,70090.0.html If you can, please help me on that, too. :open_mouth:

Now I'm going to make it CALL my cell phone!

You just send an email to your cell phone provider's SMS email gateway.

I did successfully send email from my Arduino. At some moment each attempt to upload an emailing sketch resulted in the infamous “avrdude: stk500_2_ReceiveMessage(): timeout” error. If I then try, after restarting the arduino program, to upload some other sketch everything is fine, but again, trying the email program gives again the timeout error. There must be something in the program. Does anyone have any idea what I could change to make it upload and run ?
This is the code :

[size=10pt]#include <SPI.h>
#include <Client.h>
#include <Ethernet.h>
#include <Server.h>

byte mac []= { 0xA0 ,  0xB0 ,  0xC0 ,  0xD0 ,  0xE0 ,  0xF0 };
byte ip [] = { 192,168,1, 177 };
byte gateway [] = { 192,168,1,254};  // I need this, don't think it is for everyone
byte subnet [] = { 255,255,255,0};
int port = 25; //mail

byte server []= { 194, 109, 6, 51 }; //

Client client(server, port);

boolean sendMail(char *from, char *to , char *subject , char *message) {
    Serial.println("wait for connection");
if (client.connected()) {
 client.println("HELO HalloServer");
 client.println(strcat("MAIL FROM: ",from));
 client.println(strcat("RCPT TO: ",to));
 client.println(strcat("TO: ",to));
 client.println(strcat("SUBJECT: ",subject));
 Serial.println("Mail senden QUIT");

while (client.available()) {
  char c =;
 return true;
else {
 return false;

void setup() {

Ethernet.begin(mac, ip,gateway,subnet);
char from [] = "" ;
char to [] = "" ;
char subject [] = "Arduino send Email" ;
char message [] = "you have MAIL !!!!!" ;

 if (sendMail(from, to, subject, message)) {
  Serial.println("sendMail succes");
 } else {
  Serial.println("sendMail failed");

void loop() {
  delay (1000);

Con't see anything wrong with the code (OK some tags are sneaked in, but I think they are not compilable anyway) - have you tried a 2nd board, another PC, another cable allready?

furthermore I wondered why you added the delay in loop()....

void loop() { delay (1000); }