Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:58 27 Nov 2024 Privacy Policy
Jump to

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: Australia
Posts: 847
Posted: 01:57am 27 Aug 2023
Copy link to clipboard 
Print this post

Thanks Geoff - no pressure.

Just after I hit post I got this response


  Quote  
Twilio Support (SendGrid)
Aug 26, 2023, 6:29 PM PDT
Hello Account Holder,
We have reviewed your account and have determined that Twilio’s services cannot support your account at this time due to one or more of the following:
1. Violations of Acceptable Use Policy
2. Violations of Twilio SendGrid Email Policy
3. Accounts with unresolved billing issues
4. Inability to verify provided information
Thank you for your interest in Twilio SendGrid, best of luck with your future endeavors.


Cheers,

Andrew
Edited 2023-08-27 13:12 by Andrew_G
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 04:32am 27 Aug 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 3
Posted: 06:15am 31 Aug 2023
Copy link to clipboard 
Print this post

Hi Geoff. In sendgrid do you choose web api or smtp relay.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 08:02am 31 Aug 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 275
Posted: 09:16am 31 Aug 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 3194
Posted: 09:50am 31 Aug 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 3
Posted: 10:20am 31 Aug 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 3194
Posted: 12:14pm 31 Aug 2023
Copy link to clipboard 
Print this post

  trevor j said  hi Geoff.  I need help with the verifying the api key , I have selected SMTP relay.  how do l configure application with settings.

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: Australia
Posts: 275
Posted: 11:31pm 31 Aug 2023
Copy link to clipboard 
Print this post

Hi Geoff, I think they normally recommend 2525 SMTP port, which is what i have use in the past, from their FAQ:

  Quote  Will SMTP2GO work even if port 25 is blocked?

Yes – SMTP2GO is open on different SMTP ports (25, 80, 587, 2525, 8025). We recommend using port 2525, which is open from most locations. Try a different port number if port 2525 is blocked at your location.
Ref: https://www.smtp2go.com/faq/

mike
Codenquilts
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 07:56am 08 Sep 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 847
Posted: 01:38am 09 Sep 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 1873
Posted: 11:01pm 07 Dec 2023
Copy link to clipboard 
Print this post

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.
  Quote  > run
ntp address 88.198.226.248
got ntp response: 08/12/2023 08:52:14
tcp address 13.114.210.107
Connected
220 SG ESMTP service ready at geopod-ismtpd-10

334 VXNlcm5hbWU6

334 UGFzc3dvcmQ6

235 Authentication successful

250 Sender address accepted

250 Recipient address accepted

354 Continue

Email send failed


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: Australia
Posts: 3194
Posted: 01:18am 08 Dec 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 1873
Posted: 02:00am 08 Dec 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 3194
Posted: 04:02am 08 Dec 2023
Copy link to clipboard 
Print this post

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)

  Quote  I have my own Domain name and my email is with VentraIP, would this make a difference.

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: Australia
Posts: 1873
Posted: 04:57am 08 Dec 2023
Copy link to clipboard 
Print this post

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 States
Posts: 3150
Posted: 01:51pm 08 Dec 2023
Copy link to clipboard 
Print this post

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: Australia
Posts: 1873
Posted: 07:20pm 08 Dec 2023
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 3802
Posted: 08:15pm 08 Dec 2023
Copy link to clipboard 
Print this post

IIRC the body is separated from the headers by an empty line.

John
 
PhilP

Newbie

Joined: 25/01/2017
Location: United Kingdom
Posts: 31
Posted: 08:21pm 08 Dec 2023
Copy link to clipboard 
Print this post

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
© JAQ Software 2024