Hi. I recently updated to 2015r3 and rebuilt my project. I have a few areas that use MailSocket, where I use the sendgrid service to handle these. The user can send me a plain text email through the program without needing to open their email service. I am noticing that I am not getting the emails as was prior to the update to Xojo. Are there any incompatibilities now with sendgrid that anyone is aware of? Is there something new I need to do? I have changed nothing in the code in these areas.
any error message?
Nothing. The program runs just fine. The only difference is that there are no emails that come through. Even checked spam and nothing there.
Here’s my code minus any login info for one of the areas
[code] dim mail as EmailMessage
dim strMessage as String
dim whatVersion as String
MailSocket.Address = "smtp.sendgrid.net" MailSocket.Port = 587 MailSocket.Username = "username" MailSocket.Password = "password" mail = new EmailMessage mail.fromAddress = txtEmail.Text mail.subject = "Question Posted on DTR Practice Exam from " + txtName.Text whatVersion = str(app.MajorVersion) + "." + str(app.MinorVersion) + "." + str(app.BugVersion) strMessage = "Your question will be answered as soon as possible." + EndOfLine + _ "If you have further questions, or any information you entered below is incorrect, please email email@example.com" + _ EndOfLine + EndOfLine + "Reference Number: " + lblReference.Text + EndOfLine + "Set: " + lblSet.Text + EndOfLine + _ "Question: " + txtQuestion.Text + EndOfLine + "Answer: " + txtAnswer.Text + EndOfLine + "Your Choice: " + txtUserChoice.Text + _ endofline + EndOfLine + "Student Question: " + txtYourQuestion.Text + EndOfLine + "Submitted By: " + txtName.Text + _ EndOfLine + "Email: " + txtEmail.Text + EndOfLine + EndOfLine + "Version: " + whatVersion mail.bodyPlainText = strMessage mail.AddRecipient trim(txtEmail.Text) mail.AddCCRecipient trim("firstname.lastname@example.org") MailSocket.Messages.Append mail MailSocket.SendMail[/code]
anything in the events on MailSocket?
Or you try MBS CURL Plugin to send email where you get a verbose debug log, so you can check what’s wrong.
I checked breakpoints but nothing seems to be throwing any errors. Is your CURL plugin designed for sending emails through an application?
2015r3 is a bit more strict about security settings of a SMTPSecureSocket. Try implementing the ServerError event and see what ErrorID/ErrorMessage you might be getting.
[quote=228159:@Ryan Hartz]Nothing. The program runs just fine. The only difference is that there are no emails that come through. Even checked spam and nothing there.
Here’s my code minus any login info for one of the areas
Does the mail socket go out of scope at the end of this code ?
Sending is not instantaneous
Hi Travis. Can you explain how to do that? I’m not familiar.
Hi Norman. No errors were seen during the breakpoint debug or just running.
Select your Mail Socket in the navigator, Insert an Event Handler, and select the ServerError event. Inside that event you will have access to an ErrorID and ErrrorMessage you can look at- if that kind of error is happening.
If you still have trouble, you can make a private Feedback case so we can take a look (with temporary sending credentials for testing).
Suppose your code is like
sub sendanemail() dim mailsocket as new SMTPSecureSocket // do all your code mailsocket.sendmail end sub
because you exit the sub right away mailsocket gets destroyed
and thats very likely never going to raise any error OR start to even send the emails
This is a VERY common issue when trying to send emails
They are NOT all delivered right at the instant you say “sendmail”
It takes some time and if you dont give the socket time to do it then you get no emails or only some emails being sent
Out of curiosity try the same code again on your last version of Xojo.
When I migrated one of my apps to 64 bit during the beta, I had kind of the same issue but when I caught some of the events it was Gmail blowing me an authentication error. I initially was cursing the r3 beta, but decided to try it again in the production build I did from my version control (using a 2014 version) and lo & behold, same darn thing!
In my case Gmail has locked down security, so you had to go to your Gmail settings and allow “less” secure access.
This may not be the cause however…
I now use similar to SendGrid, Mailgun and I’m migrating the email send to a HTTPS Post (API) (or curl) rather than SMTP. Will SendGrid allow that?
Thanks for the replies everyone. I am going to do some testing tomorrow morning. Too much staring at the screen for one day. Rest up and revisit when refreshed
I’ll post back tomorrow with my findings.
@Travis Hill I just performed the ServerError check and here is what I came out with:
ErrorID = 503
ErrorMessage = 503 TLS already negotiated
I have no clue what any of this means. Do you?
Yes, that’s interesting- but a bit odd in this circumstance. Can you file a Feedback report with this information (your provider SendGrid and the error) and we can dig into it further.
Thanks for your help Travis. I just submitted the feedback report: <https://xojo.com/issue/41560>
Have you check your are running the correct SSLSocket Connection type: http://documentation.xojo.com/index.php/SSLSocket.ConnectionType
Hi John. Not knowing anything about the connection type, I tried each, and none sent an email. Does it matter where it goes in the code? I entered it after the username and passoword
The code shown doesn’t use SSL so the SSL Connection type shouldn’t make any difference. This also makes the error code so strange.
@Ryan: do you use a normal socket or an SSL socket?
We’ve verified the Feedback case as an issue to resolve with the SMTPSecureSocket and this provider (SendGrid). We’re investigating a fix for a future release.