I am working on a code to send automatic email to registered users and although I do not get any errors, the mail doesn’t seem to be really send. I am sending to my own address and do not receive anything.
This is the code I use to send the mail: email.AddRecipient(txtRegEmail.text)
// Create a new SMTP socket
Var mailSocket As New SMTPSecureSocket
when you want to share code, so it will looks like Xojo Code; that will help to read it:
// Create a new SMTP socket
Var mailSocket As New SMTPSecureSocket
// Connect to Gmail
mailSocket.Address = “smtp.gmail.com”
mailSocket.Port = 465
mailSocket.ConnectionType = SMTPSecureSocket.TLSv1
mailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
mailSocket.Secure = True
mailSocket.Username = “info@storycraft-for-writers.com”
mailSocket.Password = “password”
// Add the email message to the socket and send it
mailSocket.Messages.AddRow(email)
mailSocket.SendMail
// Create a new SMTP socket
Var mailSocket As New SMTPSecureSocket
// Connect to Gmail
mailSocket.Address = “smtp.gmail.com”
mailSocket.Port = 465
mailSocket.ConnectionType = SMTPSecureSocket.TLSv1
mailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
mailSocket.Secure = True
mailSocket.Username = “info@storycraft-for-writers.com”
mailSocket.Password = “password”
// Add the email message to the socket and send it
mailSocket.Messages.AddRow(email)
mailSocket.SendMail
You have to jump some extra hoops before gmail will allow you to use smtp. Google it for more info while you wait for someone to chime in with details.
Your MailSocket will go out of scope before completing, so make that property of app, or window or something more persistent. Then you’ll hit what @Tim_Hare alluded to in his reply.
Thanks, I used a property on the window. And it looks like I have to enable the smtp in my google account yes, but this is only possible when I turn of the 2-Step Verification enabled it seems:
To help keep your account secure, from May 30, 2022 , Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.
This setting is not available for accounts with 2-Step Verification enabled. Such accounts require an application-specific password for less secure apps access. Find out more
Please use a dedicated service for this and not your own email address. I can send 200 emails per day with SendGrid. If you need to send more then have a look at AppSumo if they have a good deal for something with an API.
Thanks, I will look into that. The weird things is that I also use an app that I created with Filemaker and from that app, I can send mails without a problem using the same mail settings.