Hi
This is my code, I am try to send email using but no works
error 535,5.7.3
MailSocket.Secure = True
MailSocket.Address = “smtp.office365.com” // your SMTP email server
MailSocket.ConnectionType = SMTPSecureSocket.TLSv12
MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSTARTTLS
MailSocket.Username = Username
MailSocket.Password = Password
MailSocket.Port = 587 // Check your server for the property port # to use
When I google the error code it says “Authentication Unsuccessful”
I know a project I work with is sending email through Office365 using Xojo SMTPSecureSocket, so it does work. I didn’t configure it so I don’t know if there’s a special step like maybe Office365 has a “Less secure apps” equivalent setting?
inb4 someone goes um actually and tells you to use a transactional email service you didn’t ask about.
2 Likes
FWIW, I just tried this code, as we speak:
Var MailSocket as New SMTPSecureSocket
MailSocket.Secure = True
MailSocket.Address = "smtp.office365.com"
MailSocket.ConnectionType = SMTPSecureSocket.TLSv12
MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSTARTTLS
MailSocket.Username = "myuser"
MailSocket.Password = "mypassword"
MailSocket.Port = 587
// Create EmailMessage
Var mail As New EmailMessage
mail.FromAddress = "jeannot.muller@teccompanion.com"
mail.AddRecipient("support@xojodocs.com")
mail.Subject = "Test E-Mail"
mail.BodyPlainText = "This email was sent from a Xojo app."
// Send it
MailSocket.Messages.AddRow(mail)
MailSocket.SendMail
and bang! It works:
There a few caveats:
- You have to send from the account you are logging in.
- Don’t think that is the case for you: but if you are sending mass e-mails you have to do it in chunks. I can remember the exact threshold, but I think it is 50 messages every 30 seconds or so. Please google.
- It can be that the administrator/you disabled SMTP Authentication (globally, or per account), so I suggest verifying this: https://www.michev.info/Blog/Post/2075/controlling-smtp-authentication-for-office-365-mailboxes.
6 Likes
Thank you Jeannot !
I was trying to send a message with one of my microsoft accounts and it wasn’t working whatever I was doing.
I changed for another account and boom voilà ! It was working
I would’t have thaught about changing accounts if I didn’t read your post.
A +
Jean-Maurice
1 Like
I could never get SMTPSecuresocket to reliably work with office365. It would work intermittently but under load it would often fail. So I switched to using Monkeybreads CURLEmailMBS. It has worked without fail since changing to it.
Here I have a writeup on converting my existing code to use CURLEmailMBS:
https://forum.xojo.com/t/replacing-smtpsecuresocket-mbs-need-tls-1-3/70367
1 Like