cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure SMTP Configurations to provide e-mail via XSJS service

0 Kudos

Hi Everyone,
I'm trying to send e-mail from xsjs service. To do my case, I found some examples(link-1, link-2) which are related with my purpose. Regarding these examples, I tried to configure my system requirements on XS Admin Tool platform such as SMTP Configuration, Trust Store configuration for Certificates. But when I try to execute my xsjs service I'm getting an error which is "error connection denied".
My xsjs code and configuration details are below.
XSJS CODE

var from = "gokhanguler0@outlook.com";
var to = "gokhanguler0@outlook.com";
var subject = "test";
var message = "test";
var smtp = new $.net.SMTPConnection();
var mail = new $.net.Mail({
   sender: {
     address: from
   },
   to: [{
     address: to
   }],
   subject: subject,
   subjectEncoding: "UTF-8",
   parts: [new $.net.Mail.Part({
     type: $.net.Mail.Part.TYPE_TEXT,
     contentType: "text/plain",
     text: message,
     encoding: "UTF-8"
   })]
});
var returnValue = smtp.send(mail);
var response = "MessageId = " + returnValue.messageId + ", final reply = " + returnValue.finalReply;
$.response.setBody(JSON.stringify(response));

Thanks for your help.

Regards.

Gokhan.

Accepted Solutions (0)

Answers (2)

Answers (2)

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Gokhan,

You've set the authentication type to Auto - which means setup checks the authentication mechanisms supported by the specified SMTP server and selects one in the following order of preference: Digest-MD5, CRAM-MD5, Plain, Login, and None.

There is a high change that your SMTP service isn't compatible with the automatic mode or HANA is selecting a supported authentication method, but there isn't enough information supplied in the current setup for a successful authentication.

Therefore you should adjust the authentication type to something that your SMTP will accept - avoid using the auto mode and declare as explicit. Best way to find out which one it does accept is to manually connect to your SMTP service and understand what is going on before moving to configuration in a HANA box. Check this blog on how to issue the commands expected by SMTP during a STARTTLS communication:

https://halon.io/blog/how-to-test-smtp-servers-using-the-command-line/

I don't really know how Microsoft SMTP works with regards to authentication, but this answer tells us it does support LOGIN and PLAIN modes.

Best regards,
Ivan

0 Kudos

Hi Ivan,

I changed authentication type as Login but it did not work again and same error occured. Is there any configuration settings that I have to do in outlook or any destination configuration ? Should I close the security settings to access my email from the xsjs service ?

Thanks for your help.

Best regards.

Gokhan.

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

I believe you have to first identify if it is possible to connect to your account using command line interface. Then figure out what o do with HANA.

0 Kudos

Hi Ivan,

I tried some methods to solve the issue but there is no change. I will try this process in on-premise system. If I find any solution I share it with community.

Thanks for your help.

Best regards.

Gokhan.

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Gokhan,

You should import the complete certificate chain in the certificate list named "outlook". I've taken a look at the smtp address, this certificate is signed by:

CN = DigiCert Global Root CA
OU = www.digicert.com
O = DigiCert Inc
C = US

With an intermediate of:

CN = DigiCert Cloud Services CA-1
O = DigiCert Inc
C = US

I can only see the following certificate in you configuration files.

CN = outlook.com
O = Microsoft Corporation
L = Redmond
S = Washington
C = US

This will make the certificate not trusted at all. Unfortunately a HANA box doesn't come with CA Root and Intermediate certificates by default like your browser does. You have to import the full chain always.

Best regards,
Ivan

0 Kudos

Hi Ivan,

I add certificates to TRUST STORE which are related to login.live.com (mail server host ) and I configured mail server port as 587. But I'm still getting the same error, which is error connection denied, and I have no idea about what is wrong with my configurations. I'm sharing my last configuration details like TRUST STORE and SMTP CONFIGURATION sections.


TRUST STORE DETAILS

SMTP CONFIGURATION DETAILS

Thanks for your help.

Regards.

Gokhan.