Question
· Mar 16, 2018

Send method of %Net.SMTP reports a failure

Hi community

I created an %Net.SMTP object in my project , but when i call it's "send method" i don't find it inside the created SMTP object, so i can't also send my mail.

can some one help me?

thank's

Discussion (4)1
Log in or sign up to continue

ClassMethod SendMAil(mail As %Library.String, Url As %Library.String) As %Status
{

 Set server=##class(%Net.SMTP).%New()
 
  Set server.smtpserver="smtp.office365.com"
  //HotPOP SMTP server uses the default port (25)
  Set server.port=25
 
  //Create object to carry authentication

  Set auth=##class(%Net.Authenticator).%New()
  Set auth.UserName="noreply-service@*********.com"
  Set auth.Password="************"
 
  Set server.authenticator=auth
  Set server.AuthFrom=auth.UserName
 
 //create smtp server instance
 
 //generate mail body
 Set msg = ##class(%Net.MailMessage).%New()
 Set msg.From=server.authenticator.UserName
  Do msg.To.Insert(mail)
 Set msg.Subject="Set New Password"_$H
 Set msg.IsBinary=0
 Set msg.IsHTML=0
 Do msg.TextData.Write(Url)
 set status= server.Send(msg)
  If $$$ISERR(status) {
    Do $System.Status.DisplayError(status)
    Write server.Error
    
    Quit ""
  }
 
  Quit server.FailedSend
 

}

**********************************************************************

on my poste man i've this error: ERROR #6034 connetion failed to the SMTP server

Checking some hints for  SMTP.office365.com
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_o365admin-mso_dep365/smtpoffice365com-relay-535-573-authentication/9de8d176-1c07-4e66-b14f-148d3bd51bbf

I see that the require SSL/TLS encryption.

In your code I miss
     Set server.SSLConfiguration = "whatever you named it

This might most likely cause the problem.
 

In anticipation of your next post:  How to setup SSL/TLS configuration.
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCAS_ssltls#GCAS_ssltls_createedit