cancel
Showing results for 
Search instead for 
Did you mean: 

Using Gmail To Send Email in HANA XSJS

pinakipatra
Contributor
0 Kudos

Hi Experts ,

I am trying to send mail from HANA using gmail's smtp settings but not able to figure it out.

I have gone through the following  blogs but could not find much help.

https://scn.sap.com/thread/3738248

Following is the smtp server settings:

Below is the XSJS code


//create email from JS Object and send 

var mail = new $.net.Mail({ 

    sender: {address: "*******@gmail.com"}, 

    to: [{ address: "******@gmail.com"}], 

    subject: "XSJS Email Test", 

    parts: [ new $.net.Mail.Part({ 

        type: $.net.Mail.Part.TYPE_TEXT, 

        text: "The body of the mail.", 

        contentType: "text/plain" 

    })] 

}); 

var returnValue = mail.send(); 

var response = "MessageId = " + returnValue.messageId + ", final reply = " + returnValue.finalReply;

$.response.setBody(response);


Usually i am getting the following error

Error: error coulnd't establish connection (line 12 position 1 in *******/SEND_MAIL.xsjs)

Am I missing any step or something wrongly configured?

It would  be great if somebody can help me on this.

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

Hello Pinaki,

port 25 for smtp.gmail.com is not supported anymore. You have to use 465 for SSL or 587 for TLS.

For both cases you have to change also Transport Security Setting from "None" to "SSL/TLS".

Depending on your account setup the trust store configuration can be necessary too.

What also has to be checked is, if your HANA system can connect on network level to the SMTP server (maybe e.g. some firewall settings do not allow that).

If your system is behind a proxy, you also have to specify the proxy information in the HANA SMTP configuration.

Best Regards,

Florian

pinakipatra
Contributor
0 Kudos

Hi Florian ,

Thanks for the reply .I tried with the following settings for office 365.But getting error..

Found the following errors:

===========================

Error: error coulnd't get certificate (line 12 position 1 in /user_work/PinakiP/LEARNINGS/XSJS/XSJS/SEND_MAIL.xsjs)


I am not sure about the trust store configuration.Any help in regards to that ?

Former Member
0 Kudos

Hi Florian Pfeffer,


Could please let us know how to configure 465 SSL and its Trust Store?


Thanks

Varathan A


pfefferf
Active Contributor
0 Kudos

Hello,

you need to create an own trust store for smtp.office365.com. The SAPLOGON trust store is not valid for this of course.

Hints:

Best Regards,

Florian

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Pinaki,

I am also getting same problem and unable to send mails but previous with configuring the mail was sent perfectly but now its not working...

Are you able to send mail now?

Thanks

Varathan A

pinakipatra
Contributor
0 Kudos

I tried with gmail and office365 but was not able to send mail

pinakipatra
Contributor
0 Kudos

I tried the same thing with  smtp.office365.com and port 587   but did not worked for me