Hi All,
I have managed to get my Arduino to email via Telnet but i am having problems getting a particular string to work... any help would be greatly appreciated.
The end result would be an email with the body something like this:
TempF : 86
Everytime I send this:
client.println("TempF : 86");
The email body is blank.
If I send this:
client.println("TempF 86");
the body contains TempF 86 - as expected.
I have several hours of research into this and simply cannot come up with the solution.
client.print does not appear to work... only println
client.println(byte(58)); will place the ":" on its own line... but it must all be together as shown above.
if I place the ":" in a variable the result is a blank email also.
I have tried many things and am sure the answer will be simple... being a newbie to Arduino/C/telnet I am having some difficulty.
Any help is appreciated - Thanks in advance
Shane
Did you put a blank line in between the "head" part of the message and the body? That's the only thing that normally separates them, and if you put "Tempf: 86" in the header, most email clients will probably not display it...
westfw,
I think the answer to your question is yes...
Here is the code that i am using...
client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)/
delay(wait); / wait for a response */
client.println("MAIL From: @**.com"); / identify sender, this should be the same as the smtp server you are using /
delay(wait); / wait for a response */
client.println("RCPT To: ****@gmail.com"); / identify recipient /
delay(wait); / wait for a response */
client.println("DATA");
delay(wait); /* wait for a response */
client.println("QUIT"); /* terminate connection /
delay(wait); / wait for a response */
This will send an email to my account with the subject as expected but nothing in the body.
If i change the line in red (above) to client.println("TempF 32");
The body of the email contains "TempF 32"
BTW - the reason for the very specific formatting is that i am attempting to add records to a ZOHO Data Base and the required format is "ColumName : Data"
I am attempting to create an Internet Temperature and Humidity Logging Application with ZOHO as the preferred back end.
westfw, Thanks so much that was what i needed... just did not understand what was meant the first time by blank line.
If i may ask... is that documented somewhere that i missed or is it just one of those things you knew?
I also have one other question on the client.println syntax... it is related but not sure if I should ask now or start a new thread.
In the example of "TempF : 32" the 32 is a variable ... can you point me in the right direction for the syntax to print "TempF : " + variable ?
westfw,
Ok... that blank line really did the trick!
Now the client.print is working also .... so i just did this
client.print("TempF : ");
client.println(TempF);
To get the results i needed in the body of the e-mail.
(That answers my second question above.)
I assume that telnet just needed to know where the header stopped and the body started.
I assume that telnet just needed to know where the header stopped and the body started.
It's more likely that the email DID contain the "TEMP:" line, but your mail client chose not to display it (most modern mail clients choose not to display non-standard header lines by default.)
Did you try looking at the messages with 'view raw source' or equivalent?
Telnet doesn't care (or even know) about header/body separation, and most mail server software will leave all the headers that it sees (and add some more.)
So two things to be aware of: the blank line between headers and body, and there is special handling for any line that starts with a ".". So make sure you have the empty line between headers and body, and don't start lines with a "." and you'll be fine
All,
Wanted to say thanks for your help!
This section of the project is now working even better than I had hoped
I am looking forward to the day when i know enough to help out.