Email from the core

Hi @jboswell,

Awesome! I saw something like this when I was sending mail using Dreamhost’s smtp servers. Hmm, yeah that does seem more like a glitch in my code vs. a weird smtp standard :slight_smile:

Thanks,
David

Hey Jboswell,
I see you’re using gmail, which is what I’m trying to do. I can’t get it to authenticate, I get to the starttls, but can’t get the user and password to get accepted. Can you show me the code that gets you thru the authentication? I’m using the bit below. I’ve tried with and without the extra ehlo, I’ve seen it both ways in different places, and I’ve tried using the Username and password on separate lines as well as separated by a comma, as they are below. Here is also the serial output, maybe that helps. I’ve had to change some of the response blocks to get it to go this far, but I can’t seem to get it to deal with the authentication.

Can you guys see what I’m doing wrong?

Jim

int handshake(char *smtpServer) {
//wait for the server to say something.

flushToSerial(client); //client.flush();
Serial.write("waiting for the server to say hello...\n");
if (blockForResponse("220", 5000) == 0) {
	//handshake failed.
	return 0;
}
idle();

Serial.write("Saying hello back.\n");
echoSocketWrite(client, String("EHLO ") + String(smtpServer) + String("\r\n"));
if (blockForResponse("250", 1250) == 0) {
	//handshake failed.
	return 0;
}
idle();

return 1;

}

int authenticate(char *username, char *password) {
Serial.write(“logging in…\n”);

echoSocketWrite(client, String("starttls") + String("\r\n"));
blockForResponse("220", 5000);

echoSocketWrite(client, String("EHLO") + String("\r\n"));
blockForResponse("2.0.0", 5000);

echoSocketWrite(client, String(username) + String(",") + String(password) + String("\r\n"));
blockForResponse("Ready", 5000);

//echoSocketWrite(client, String(password) + String("\r\n"));
//blockForResponse("Ready", 5000);
 
idle();
return 1;

}

here we go…Connected!
waiting for the server to say hello…
220heard response.
Saying hello back.
mx.google.com ESMTP ac5sm8880618pbc.37 - gsmtp
EHLO smtp.gmail.com
mx.google.co250heard response.
logging in…
-mx.google.com at your service, [75.70.130.131]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 CHUNKING
starttls
-mx.google.co220heard response.
2.0.0 Ready to start TLS
EHLO
2.0.0heard response.
Ready 64bit gibberishblahblah,64bitgibberish
Readyheard response.
sending mail…
MAIL FROM:email@gmail.com
RCPT TO:email@dot.com
DATA
from: email@gmail.com
to: email@dot.com
subject: Email from a Core!

Body body body

I see you're using gmail

I am only sending to a gmail account, I am using a separate smtp service to send out emails. It's really easy to use, and it's like 600 emails a day on the free account:

I was using one or two other ones but I had problems with those, can't remember what the problems were off the top of my head though.

J

Well, thanks for the help, guys. I finally got the email to go, but had to change to a different smtp server to get it done. Now they are going out well, and with no errors after this mornings session. The email I’m sending is going to a growl address, and it notifies my iPhone when the email gets sent, which is the whole purpose of what I’m trying to do, works well.

Next I have to figure out how to use interrupts, then hook this thing up to a battery and see if I can get 8 hours of life out of it!

Thx,
Jim

2 Likes

This is such a great feature, anyone had made this into the Spark library for web Build ?

Hi Guys,

I’m trying to get this to work, it seems to work - however I do not receive any mail :frowning: … not in the spam either…

here’s my serial output:

Connected!
waiting for the server to say hello…
220heard response.
Saying hello back.
BLU436-SMTP69.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Fri, 8 Aug 2014 02:10:55 -0700
EHLO smtp.live.com
BLU436-SMTP69.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Fri, 8 Aug 2014 02:10:55 -070250heard response.
logging in…
AUTH LOGIN
-BLU436-SMTP69.smtp.hotmail.com Hello [143.93.250.30]
250-TURN
250-SIZE 41943040
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-TLS
250-STARTTLS
250 OK
530 5.7.0 Must issue a STARTTLS command first
timed out.
base64_encode_raune.frankjaer@hotmail.com
530 5.7.0 Must issue a STARTTLS command first
timed out.
base64_encode_blahblahblah
530 5.7.0 Must issue a STARTTLS command first
timed out.
sending mail…
MAIL FROM:raune.frankjaer@hotmail.com
RCPT TO:raune@frankjaer.de
DATA
from: raune.frankjaer@hotmail.com
to: raune@frankjaer.de
subject: Email from a Core!

Body body body

Any ideas what I’m doing wrong highly appreciated :smile:

1 Like

ok so I created a new topic for this seeing the thread is rather old: https://community.spark.io/t/troubleshooting-email-from-core/6273

1 Like