Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Sending EMails from the PicoMiteWeb
Page 2 of 3 | |||||
Author | Message | ||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Thanks Geoff - no pressure. Just after I hit post I got this response Cheers, Andrew Edited 2023-08-27 13:12 by Andrew_G |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
Hmm... this is a bummer. It took a lot of searching to find SendGrid which, at the time, seemed the only service that had a useable SMTP interface. I don't really blame them. They provide the free service to help prospective (paying) clients test their system, not hobbyists like us. Google would have been good (everyone has a Google account) but the SMTP interface is poorly documented and seems beyond what the WebMite can handle. I will do some more searching. Geoff Geoff Graham - http://geoffg.net |
||||
trevor j Newbie Joined: 29/08/2023 Location: AustraliaPosts: 3 |
Hi Geoff. In sendgrid do you choose web api or smtp relay. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
It is smtp relay. I think that detailed instructions are needed. Geoff Geoff Graham - http://geoffg.net |
||||
MikeO Senior Member Joined: 11/09/2011 Location: AustraliaPosts: 275 |
Geoff, Have you had a look at SMTP2GO I believe it still has a free acc, I have use it in the past and from memory it was reasonably easy to use I believe. Mike Codenquilts |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
Thanks, SMTP2GO looks useable. Although it appears that they don't use SMTP. Damn. Geoff Geoff Graham - http://geoffg.net |
||||
trevor j Newbie Joined: 29/08/2023 Location: AustraliaPosts: 3 |
hi Geoff. I need help with the verifying the api key , I have selected SMTP relay. how do l configure application with settings. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
Wow... you need to provide a lot more information. What application? Have you read the documentation? What have you tried? etc, etc, ... Geoff Graham - http://geoffg.net |
||||
MikeO Senior Member Joined: 11/09/2011 Location: AustraliaPosts: 275 |
Hi Geoff, I think they normally recommend 2525 SMTP port, which is what i have use in the past, from their FAQ: Ref: https://www.smtp2go.com/faq/ mike Codenquilts |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
For anyone experiencing issues with registering for SendGrid I have found that SMTP2GO also offer a free service that does not seem to be as hard to use (thanks to MikeO for the pointer). To get started you need to create a free login at SMTP2GO (https://www.smtp2go.com/), register a Verified Sender and create an associated username and password. Both then need to be converted to Base64 encoded strings (the following website will do this for you: https://www.base64encode.org). The Base64 encoded username should be used to replace the nnnnnnnnnn string in the first line of the following program while the Base64 encoded password should be used to replace the xxxxxxxxxxxx in the second line. The other four lines at the start of the program should also be replaced with your data: CONST userBase64$ = "nnnnnnnnnnnn" CONST paswdBase64$ = "xxxxxxxxxxxx" CONST mailfrom$ = "from@server.com" CONST mailto$ = "to@server.com" CONST subject$ = "Test EMail" CONST message$ = "Test of SMTP2GO" CONST cr = Chr$(13)+Chr$(10) DIM buff%(4096/8), body$ body$ = "From: " + mailfrom$ + cr + "To: " + mailto$ + cr body$ = body$ + "Subject: " + subject$ + cr + cr body$ = body$ + message$ + cr + "." + cr WEB OPEN TCP CLIENT "mail.smtp2go.com", 2525 WEB TCP CLIENT REQUEST "EHLO" + cr, buff%() WEB TCP CLIENT REQUEST "AUTH LOGIN" + cr, buff%() WEB TCP CLIENT REQUEST userBase64$ + cr, buff%() WEB TCP CLIENT REQUEST paswdBase64$ + cr, buff%() WEB TCP CLIENT REQUEST "MAIL FROM: " + mailfrom$ + cr, buff%() WEB TCP CLIENT REQUEST "RCPT TO: " + mailto$ + cr, buff%() WEB TCP CLIENT REQUEST "DATA" + cr, buff%() PAUSE 300 WEB TCP CLIENT REQUEST body$, buff%() PAUSE 300 WEB CLOSE TCP CLIENT IF LINSTR(buff%(), "250 OK") = 0 THEN PRINT "Email send failed" Else Print "Email sent OK" Note that the mailfrom$ email address used in the above program MUST be the same as that used when you registered the Verified Sender with SMTP2GO. If they are not the same SMTP2GO will reject the email (this is an anti spam precaution). I will probably update the Watering Controller software to use this SMTP2GO. Geoff Geoff Graham - http://geoffg.net |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hi Geoff, I'm not sure of what I did but whatever it was - it worked (eventually)! Using your code above I can now send an email to myself! Setting up the SMTP2GO would be simple for someone who knew what they were doing and there were no intrusive questions. A big thankyou! Cheers, Andrew Edited 2023-09-09 11:41 by Andrew_G |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
Problems again, I'm using SENDGRID to try and send email, when I run I get the following using "Longstring Print Buff()" to print results from SENDGRID. It seems SENDGRID is happy with everything but it doesn't send. Edit. Previously I used ESP basic on an ESP8266. The only code needed was... EMAIL.SETUP "server address", 465, "me@------.org", "Password" Sub SEND vbcrlf$ = chr$(13) + chr$(10) msg$ = vbcrlf$ + "message " +RTC.Time$ + " " + RTC.Date$ print EMAIL ("from address", "to address", "Title - ", msg$ End Sub Edited 2023-12-08 09:16 by palcal "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
palcal I'm not sure what code that you are using (is it mine?) but the body needs to be formatted correctly and terminated with a period (.) on a line on its own. For example: From: fred@example.com To: foo@example.com Subject: Test This is the body of the email . Note: Your from address MUST be registered in your SendGrid account. The above is sent in the one transaction. Geoff Geoff Graham - http://geoffg.net |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
I have used your code, copied and pasted. And the from address is the same one I used for my SendGrid account. I'll check it again. This is that part of the code. body$ = "From: " + mailfrom$ + cr + "To: " + mailto$ + cr body$ = body$ + "Subject: " + subject$ + cr + cr body$ = body$ + message$ + cr + "." + cr I have my own Domain name and my email is with VentraIP, would this make a difference. Edited 2023-12-08 12:09 by palcal "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
The only thing that I can think of is to make sure that cr is defined as cr/lf as follows: CONST cr = Chr$(13)+Chr$(10) No, I don't think so. I'm at a loss to see what could be going wrong. Geoff Geoff Graham - http://geoffg.net |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
Cr is defined OK. My code is..... Timer = 0 Do While MM.Info(ip address) = "0.0.0.0" If Timer > 5000 Then CPU Restart Loop Const cr = Chr$(13)+Chr$(10) Const keyBase64$ ="U0cuWXhQTEdEb2RRU2VGNVM5WUxockUxdy5Kb2o1dTYxSFlDY05ETTRtbEEtcnY4VFZsd1dtbFpDRHVZeWJIQmlManpV" Const mailfrom$ = "name@*********.org" Const mailto$ = "name@*********.org" Const subject$ = "Test EMail" Const message$ = "Test of SMTP relay" Const cr = Chr$(13)+Chr$(10) Dim buff%(4096/8), body$ body$ = "From: " + mailfrom$ + cr + "To: " + mailto$ + cr body$ = body$ + "Subject: " + subject$ + cr + cr body$ = body$ + message$ + cr + "." + cr WEB OPEN TCP CLIENT "smtp.sendgrid.net", 2525 WEB TCP CLIENT REQUEST "AUTH LOGIN" + cr, buff%() WEB TCP CLIENT REQUEST "YXBpa2V5" + cr, buff%() WEB TCP CLIENT REQUEST keyBase64$ + cr, buff%() WEB TCP CLIENT REQUEST "MAIL FROM: " + mailfrom$ + cr, buff%() WEB TCP CLIENT REQUEST "RCPT TO: " + mailto$ + cr, buff%() WEB TCP CLIENT REQUEST "DATA" + cr, buff%() WEB TCP CLIENT REQUEST body$, buff%() Pause 500 WEB CLOSE TCP CLIENT If LInStr(buff%(), "250 Ok:") = 0 Then Print "Email send failed" "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
Do you mean to have 2 "cr"s following Subject? PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
That is how it is in Geoff's code. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3802 |
IIRC the body is separated from the headers by an empty line. John |
||||
PhilP Newbie Joined: 25/01/2017 Location: United KingdomPosts: 31 |
After the initial difficulty of SENDGRID accepting me and several exchanges reassuring them, I have been using Geoff's program for months without problems. I just followed the steps In Geoff's instructions exactly and it worked. I am sending myself emails from my security system. On your account page with SENDGRID there is a dashboard which shows how many emails you have to them and how many they forwarded. Before my account was set up, I could see that I had sent messages but they had not forwarded them. Phil |
||||
Page 2 of 3 |
Print this page |