cancel
Showing results for 
Search instead for 
Did you mean: 

Cloud SDK mail-client send using On Premise SMTP MAIL Destination

martin-kl
Explorer

Hi,

i was super excited to learn about the new Mail Client in Cloud SDK and wanted to include it in our solution but failed. So I went over Ahmet's Blog post and tried it in this simple setup (BAS, new CAP project with the single endpoint, new service instances on my trial account and using "cds bind" to test it from BAS) but I still cannot figure it out.

According to the docs, using an On Premise mail server should be as simple as configuring a destination with proxy type "OnPremise" and Cloud SDK would handle the SOCKS5 proxy. So I configured our CC with a Cloud To On-Premise Mapping of a virtual system "mail.server.com:25" to our internal mail server also running on Port 25 (TCP).

I then created the following destination:

using "mail.smtp.starttls.enable: true" and "mail.transport.protocol: smtp" for the non-readable properties (Mail server accepts un-authenticated, non-TLS requests on port 25 originating from our internal network. I have to set BasicAuthentication since NoAuthentication is rejected by mail-client#buildMailDestination. Using the same parameters without Authentication does in fact work with Java using the template from https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/using-tcp-protocol-for-cloud-applicat...).

However, cloud sdk complains that "The proxy configuration is undefined, which is mandatory for creating a socket connection" (Source of Error).

So I started to debug the destination and stumbled upon the connectivity-service#addProxyConfigurationOnPrem method that seems to provide the expected Socks proxy to the destination, but that method is not invoked. Turns out that destination-service-types#isHttpDestination evaluates to "false" as the MAIL destination has no url and the type is set, which in turn results in destination-from-service#getDestinationFromDestinationService to skip the addition of the proxy setting.

So my question is: am I even correct to use a destination of Type "MAIL" with Proxy Type "OnPremise", setting mail.smtp.host to the virtual host of the CC and mail.smtp.port to the port? Or did I stumble upon an issue with the new mail client and destination service combination?
Since I tried to "fix" the isHttpDestination method to add the proxy on MAIL Destinations as well but still run into an error (namely a ECONNRESET), I'm not sure anymore....

Best
Martin

View Entire Topic
Junjie
Advisor
Advisor
0 Kudos

Hi martin-kl ,

Thanks for reaching out.

I guess a similar issue was created here in our open source repo, where you can find an example of our e2e test destination.

martin-kl
Explorer
0 Kudos

Hi Junjie,

thanks for your quick response. The Github issue helps and I adapted my code to use "getDestination" and call "addProxyConfigurationOnPrem" as given here. I also tried various destination settings similar to your e2e destination, but I still can't get over ECONNRESET

SocksClientError: read ECONNRESET
at SocksClient.closeSocket (/home/user/projects/mail-on-premise/node_modules/socks/build/client/socksclient.js:392:32)
at SocksClient.onErrorHandler (/home/user/projects/mail-on-premise/node_modules/socks/build/client/socksclient.js:365:14)
at Socket.onError (/home/user/projects/mail-on-premise/node_modules/socks/build/client/socksclient.js:227:38)

That error is caught exactly 10 seconds after connecting the socket in SocksClient#createConnection and I am not yet able to find any trace of that request in my CC logs, so I'm not sure if it's an error on the connectivity service/destination side or if it's a problem with our Mail Server or CC config.

Best
Martin

Junjie
Advisor
Advisor
0 Kudos

For those who faced the same issue, the original GH issue has been solved.