Question
· Nov 4

Operation Email sender error #6034 connection with SMTP not successfull

I am developing a business operation that receives a request, creates a message with the data contained in it and sends it to an outlook email. For testing purposes both the sender and the destination are the same email account
This is the code:
Class BO.AlertEmailSender Extends Ens.BusinessOperation{

Parameter ADAPTER = "EnsLib.EMail.OutboundAdapter";
Property Adapter As EnsLib.EMail.OutboundAdapter;
Parameter INVOCATION = "Queue";
Method OnMessage(pRequest As Messages.AlertMsgToEmail, Output pResponse As Messages.AlertResponse) As %Status
{
    set sc = $$$OK
    Set msg = ##class(%Net.MailMessage).%New()
    Set msg.Subject=pRequest.mailObject
    set msg.From = pRequest.sender
    Do msg.To.Insert(pRequest.destination)
    Set msg.IsBinary=0
    Set msg.IsHTML=0
    set sc = msg.TextData.Write(pRequest.txtMessage)
    if $$$ISERR(sc) {    
        set ErrorText = "error: 'Write message stream error',"_$CHAR(10)_"details: '"_$SYSTEM.Status.DisplayError(sc)_"'"
        set ErrorCode = "WRT001"
        $$$LOGINFO(ErrorText)
    }
    Set smtp=##class(%Net.SMTP).%New()
    Set smtp.smtpserver="smtp-mail.outlook.com"
    Set smtp.port="587"
    //Set smtp.secure="STARTTLS"
    Set smtp.timezone="LOCAL"
    set smtp.SSLConfiguration = "smpt.office365.com"
    set smtp.UseSTARTTLS = 0
    Set auth=##class(%Net.Authenticator).%New()
    Set auth.UserName=pRequest.sender
    Set auth.Password="password"
    Set smtp.authenticator=auth
    Set smtp.AuthFrom=pRequest.sender
    //set auth.MechanismList = "PLAIN,LOGIN"
    Set sc=smtp.Send(msg)
    If $$$ISERR(sc) {
    Do $System.Status.DisplayError(sc)
    $$$LOGINFO(smtp.Error)
    Quit ""
  }
    // send email  
    //set sc = ..Adapter.SendMail(msg)
    // check for errors
    if sc {
        set report = "Email sent"
    } else {
        set report = "Email NOT sent"
        do $System.Status.DisplayError(sc)
        $$$LOGINFO("Send Failed: "_$System.Status.DisplayError(sc))
    }
    $$$LOGINFO("STATUS SEND: "_sc)
    set pResponse = ##class(Messages.AlertResponse).%New()
    set pResponse.msgStatus = report
    set pResponse.mailStatus = 1
    quit sc
}
}

In the InterSystems production portal I have set the operation, activated it and configured the base settings and connection settings as this
Server SMTP = smpt.office365.com
Port SMTP = 587
Credentials = credentials
Config SSL = smpt.office365

In the past I had obtained these errors: (translated from Italian)
-when I had wrongly defined smtpserver="smpt.office365.com" I obtained error #6031 "impossible to open connection TCP/IP"
- when SSLConfiguration was not present I obtained error #6034 "connection with server SMTP not successfull during command MAIL FROM:<READ>zSend+122^%Net.SMTP.1"
I do not receive anymore these errors after the corrections present in the code above, but I obtain error #6034
Connection with SMTP server not successfull during command init: <READ>zGetResponse+5^%Net.SMTP.1.
How do I proceed?

Product version: IRIS 2021.1
Discussion (3)3
Log in or sign up to continue