Issue emailing data

Hi. Something really bizarre happened. I built some areas of my desktop app that will send an email to me (ask a question, report a bug, etc). In my testing up to yesterday, everything was working just fine. Enter an email address, click send, I’d get the email. Today for some reason, none of these email features in my app are working now. I logged onto my gmail account and am able to manually send and receive a message to and from other accounts but just cannot do it through the app. Can anyone help? I’ve changed nothing in these features between yesterday and today.

[code] dim mail as EmailMessage
MailSocket.Address = “
MailSocket.Port = 465

MailSocket.Username = “
MailSocket.Password = “mypassword”
MailSocket.Secure = True

mail = new EmailMessage
mail.fromAddress = “
mail.subject = “testing email”
mail.bodyPlainText = TextArea1.Text

mail.AddRecipient trim(TextField1.Text)

MailSocket.Messages.Append mail

Are the Error or ServerError event handlers called? Is there anything in LastErrorCode?

Thanks Paul. It’s something with my computer. I compiled it and threw it on the Mac, tested it, and the email was sent. Time for a new PC :slight_smile:

Sorry to get all worried on everyone for nothing

[quote] MailSocket.Address = “
MailSocket.Port = 465[/quote]

Are you sure these parameters are working with all provider ?

It’s also worth pointing out that gmail changes their policies rather frequently. If they decide to stop allowing relaying email from anywhere on the planet without you having logged in from there through a browser, you’ll be stuck.

SOME providers require that you make a POP or IMAP connection before trying to send something through SMTP.

@Greg: POP over SMTP isn’t used anymore - really.

@Ryan: If you only send emails rarely then your approach is okay. But there are email providers out there, which specialise in email sending and are much safer than Gmail. Check out Mandril (from the Maichimp guys). For my app I use Sendgrid. I can send 200 mails a day for free.

I’m very interested with your solution.
Can you share with us some piece of code to understand a bit the logic between a Xojo application and Sendgrid (or Mandril) service ?

Sending emails with Sendgrid is very simple. You need to setup your account and then use username and password from Sendgrid. The email code itself is identical to the one from Gmail:

socket1.address = "" socket1.port = val(PPPort.Text) socket1.username = "username" socket1.password = "password"


Very easy !
In another post ( where I detail my personal need, Greg O’Lone warm me to use this way, coding in the application my username and password and suggesting to use instead to call a web script.
And I must agree with him. What do your application/user if Sendgrid is closed or if you want to go with another provider ?

Of course, I obfuscate user name and password. Sendgrid is a dedicated service. Should they fold I’ll simply change to another service. The webscript isn’t really more secure.

Ok. I suppose your application is for your own use or are the parameters (“”, …) not in code of the application in this case ?

The Gmail solution has been working for me so far. However, today I received an email from Google saying that there was suspicious activity on my account. There was one of my customers who registered the software (email would be sent to me) in CA, and to Google, it showed an email attempting to be sent from a computer in another state. I want to bypass this in the future. Are there any settings you may be aware of in Gmail that I can change?

I may look more into Mandrill and SendGrid should I not be able to get this corrected with Gmail.


I’ve adopted the Greg O’Lone’s suggestion : use an HttpSecureSocket to ask to my webserver to send me a mail.
See the post

Best regards