Written by

Question RKumar · Sep 26, 2023

How to use SMTP protocol with TLS and SSLConfiguration

Hi All,

In the below code, How to Add SSLConfiguration and TLS. Please advise.

My sample code.

set s=##class(%Net.SMTP).%New()
;set auth=##class(%Net.Authenticator).%New() 
;set auth.UserName=[["myUser"]]
;set auth.Password=[["myPassword"]]
;set s.authenticator=auth
set s.smtpserver="relay.abc.com"
set s.timezone="-0400" 
set m=##class(%Net.MailMessage).%New()
set m.From="test@company.com"
do m.To.Insert("kumars@test.com")
do m.To.Insert("test1@another.com")
set m.Subject="Test IRIS mail 1"  
do m.TextData.Write("This message has been sent using an SMTP server ")
set status=s.Send(m)
if 'status do $system.OBJ.DisplayError(status)
Q
Product version: IRIS 2023.1

Comments

Mary George · Sep 26, 2023

Hi  Subramani, 

Try the code below:

 set s=##class(%Net.SMTP).%New()
 set s.smtpserver="relay.abc.com"  
 set s.port = <<portNumber>>
//depending on your smtp server
 set s.UseSTARTTLS = 1
//The name of the TLS/SSL configuration to use for smpts requests
 set s.SSLConfiguration = "nameofSSLToUse"

0
Ashok Kumar T · Sep 26, 2023

Hi @RKumar

You need to set the properties SSLConfiguration and UseSTARTTLS for enabling SSL configuration

set smtp=##class(%Net.SMTP).%New()
set smtp.SSLConfiguration="TestSSL";your SSL configured name in System Management Portalset smtp.UseSTARTTLS=1/*
 ... Additional required property set
*/
0
RKumar · Sep 29, 2023

Thanks for the response Mary Kutty and Ashok.

I can able to send mail with those settings.

How to confirm the changes? Is this mail from TLS-enabled mail or not?

0