Using the following code I cannot seem to get anything to work using the smtp.office365.com SMTP server. The below code returns a "504 5.7.4 Unrecognized authentication type".
Following is a link to a article explaining the requirements (same article in many posts). https://www.unifeyed.com/portal/knowledgebase/16/How-do-I-use-Office365-for-SMTP.html
do wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")
loSmtp.cMailServer = "smtp.office365.com"
loSmtp.cSenderEmail = "OfficeAdmin@xxx.org"
loSmtp.cSenderName = "companyName - Department"
loSmtp.cUsername = 'OfficeAdmin@xxx.org'
loSmtp.cPassword = 'password'
loSmtp.lUseSsl = .T.
loSmtp.nServerPort=573
loSmtp.cLogfile = 'testmail.log'
loSmtp.cRecipient = 'me@xxx.com'
loSmtp.cSubject = 'smtp Send test'
loSmtp.cContentType = 'text/html'
loSmtp.cMessage = 'This is a test sending from smtp'
loSmtp.cAlternateContentType = "text/plain"
loSmtp.cAlternateText = "Plain text can go here."
IF !loSmtp.SendMail()
wait window loSmtp.cErrorMsg
ELSE
wait wind 'SENT'
ENDIF
Using wwClient 6.0 tools, Windows 10, Foxpro 9 I have tried many variations of the above code without success. Hopefully someone else has gotten this to work.
Make sure nMailMode
is set to 0
. It should be set to .NET Mail Mode.
Defaults have changed at some point and offhand I'm not sure if .NET mode is the default.
+++ Rick ---
HI there, I'm having the same problem with Office365. I do not have 2 factor auth setup and the account is setup for authenticated SMTP. My sample code looks nearly identical to above, but just in case...
Do wwsmtp.prg
oSMTP = Createobject("wwSmtp")
oSMTP.nMailMode = 0
oSMTP.cMailServer = "smtp.office365.com" &&:587"
oSMTP.nServerPort = 587
oSMTP.lUseSSL = .T.
oSMTP.cusername = "myuser@mydomain.com"
oSMTP.cpassword = "mypassword"
oSMTP.cSenderName = "Me"
oSMTP.cSenderEmail = "myuser@mydomain.com"
oSMTP.cRecipient = "myothertestuser@myotherdomain.com"
oSMTP.cSubject = "Test"
oSMTP.cMessage = "Test at " + Ttoc(Datetime())
oSMTP.cContentType = "text/html"
llresult = oSMTP.sendmail()
If llresult
Messagebox("Message sent successfully.",0+64)
Else
Messagebox(oSMTP.cerrormsg,0+48)
Endif
Again, with two different accounts on two different outlook365 domains, this times out. Any help would be greatly appreciated!
Peace,
Steve
Just a bit more testing... I was able to successfully send through the original account with .net smtp connector, so the account seems to be working ok:
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim smtpClient As New SmtpClient("smtp.office365.com")
smtpClient.Port = 587
smtpClient.Credentials = New Net.NetworkCredential("tech@xxxxx", "xxxxxxxxx")
smtpClient.EnableSsl = True
smtpClient.Send("tech@xxxxxxx", "showie@xxxxxxxxxx", "test message 1", "Here is the body of the email")
End Sub