I’m developing an app in which the result of data processing will be send via email using the Office365 account of my customer.
I have already created several applications with email sending with different smtp and different configuration without any problem.
This is the simplified used code:
[code] Dim mail as New EmailMessage
Dim SMTPSecureSocket1 as New SMTPSecureSocket
SMTPSecureSocket1.address = “smtp.office365.com”
SMTPSecureSocket1.port = 587
SMTPSecureSocket1.Secure = True
SMTPSecureSocket1.ConnectionType = 3
SMTPSecureSocket1.Username = “sender@domain.com”
SMTPSecureSocket1.Password = “mypassword”
SMTPSecureSocket1.Connect
mail.fromAddress= “sender@domain.com”
mail.subject= “test”
mail.AddRecipient “recipient@domain.com”
mail.bodyPlainText = “Test email through smtp.office365.com”
SMTPSecureSocket1.DeleteAllMessages
SMTPSecureSocket1.Messages.Append mail
SMTPSecureSocket1.SendMail[/code]
With this code, always I can send email, but with Office365, the email doesn’t start.
All parameters are correct and using them on Mozilla Thunderbird, all works fine.
I’ve monitored the events of SMTPSecureSocket1; after the event “ConnectionEstablished” with no error code, there’s the event “Error” with code 103.
To exclude firewall block, in addition to having tested the app into the lan of my customer, I’ve tested it also from my office with the same result.
My customer has other customized applications, developed with VisualBasic; that ones can send email with the same parameters.
Is there someone that have tested Xojo to send emails through Office365?
Pietro
Have you tried ConnectionType 3? Port 587 for SMTP is generally using TLS as opposed to pure SSL. This means the socket negotiates encryption via a ‘STARTTLS’ command.
Yes Phillip, I’ve tried, as you can see in the code I’ve posted at the start of this post.
SMTPSecureSocket1.ConnectionType = 3
You could also try via our SQL plugin which supports more options.
e.g. TLS v1.2.
@Christian: SQL plugin? Don’t you mean curl?
CURL plugin of course. Sorry.
Old thread, but I hit on the very same problem with smtp.office365.com except that I am using Christian’s Curl-Plugin:
dim c as new CURLSMBS
dim result as new CurlEmailMBS
result.SetServer(“smtp.office365.com:587”,true)
result.SMTPUsername=aUserName
result.SMTPPassword=aPassword
result.Subject=“subject”
result.SetFrom(“me@me.com”,“just Me”)
result.HTMLText=“some html”
result.PlainText=“some plain text”
result.AddTo(“someone@somewhere.com”,“Some Body”)
// c.OptionTLSAuthType=“SRP” Tried this too, made no difference
// c.OptionTLSAuthUsername=me.SMTPServer.mUserName
// c.OptionTLSAuthPassword=me.SMTPServer.mPassword
if c.Lasterror<>0 then
break //don't hit on this, so far so good
end if
if c.SetupEmail(message) then
dim errorCode as integer=c.PerformMT //returns error 35 (i am in a thread here)
dim errorMessage as string=c.LasterrorMessage
always results in: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Ah, thanks. The only significant difference I can spot is that the code there uses theMailServer.SMTPConnectionMode = SMTPSecureSocket.ModeSTARTTLS and I have yet to find a similar command in the CURLSMBS.
I cannot easily switch to SMTPSecureSocket, I’m afraid…
SO we try with SSL 2/3 and fail.
you may need something like:
dim c as CURLSMBS
c.OptionUseSSL = c.kFTPSSL_ALL
c.OptionSSLVersion = c.kSSLVersionTLSv12
to switch to TLS 1.2
Hi, thanks, but unfortunately it still fails with the same error message. I tried all 4 possible c.OptionSSLVersion-values there…
What options do you use?
URL with smtp, not smtps.
Port should be 587, I think.
result.SetServer(“smtp.office365.com:587”,false)
You first connect normal and later upgrade via StartTLS to an encryption connection.
Connecting right away goes via SSL v2/3.
That did indeed solve the problem, thank you very much!