gmail and sign-in attempt prevented

Hi, I’ve made and web-app. Now I want to add sending mail. But 2 out of 3 email addresses I’ve tested with fails. Google reports: Sing-in attempt prevented and says my app does not meet modern security standards.

So how to I get this to work. ?? how do I set up the gmails to work… or is it something to be done at the xojo end of my problem ?

code for sending is:
dim myfile as Folderitem = SpecialFolder.UserHome.child(“Downloads”).Child(“test_download.pdf”)

dim file as new EmailAttachment

sendMailsocket.Secure = TRUE
sendMailsocket.ConnectionType = 2
sendMailsocket.SMTPConnectionMode = 0
SendMailSocket.Port = 465 // Check your server for the property port # to use
SendMailSocket.Address = “” // your SMTP email server
sendMailsocket.Username = “**" // username, full email
sendMailsocket.Password = "
” // password

// Create the actual email message
Dim mail As New EmailMessage
mail.FromAddress = “
mail.Subject = “Test Email from Xojo”
mail.BodyPlainText = “Hello, World! sendt som shortcut”
mail.Headers.AppendHeader(“X-Mailer”, “Xojo SMTP Example”) // Sample header

file.MIMEType = “application/pdf”
'file.loadFromfile(GetFolderItem(myfile.NativePath, folderitem.PathTypeNative))

mail.Attachments.Append file

// Add the message to the SMTPSocket and send it

Log in to each account through your browser and enable access for less-secure apps at this link. :slight_smile:

With “less secure access” turned off, gmail is enforcing oAuth 2.0.

But is there a way to make my app more secure ?

Like @Christian Wheel say use the oAuth 2.0
here is the api link OAuth2

Don’t use Gmail for sending emails. Really.

Use free plans of SendGrid or Mandril or someone else.

Your connectiontype property is incorrect for one thing. You should be using value 5, TLSv1.2. Also, I highly doubt they use port 465 any more.

OK, lots of good stuff here. But about SendGrid or Mandril, how do I set the email so that is is from an actual sender, the email send should show up the that users outbox… this is a system for contracts. So the senders outbox should get a copy and that email going out has to come from the users email to the customers email.

And we are not talking big time number of emails… maybe 100 to 200 each day in the future. Not big as send grid … :slight_smile:

sendGrid was really nice thanks!