3

I am looking at WSO2's Ballerina programming language. I don't see the module or package that allows the ballerina code to call SMTP server and send email. The only thing close to SMTP is the Gmail connector, but that is not what I am looking for. I expect to write a Ballerina script to chain some services/endpoints but also want to trigger an email by utilizing the company's internal SMTP relay server. Does anybody have any idea?

chj915
  • 41
  • 2
  • Theres are issues created in repository for this feature. https://github.com/ballerina-platform/ballerina-lang/issues/8617 , https://github.com/ballerina-platform/ballerina-lang/issues/4378. – hYk Dec 06 '18 at 07:07

2 Answers2

1

You can import email module in ballerina org into your .bal file and send emails.

import ballerina/email;

Please refer to the following documentation depending on your Ballerina version path for email sending capabilities.

[1] Swan Lake Alpha2 - https://ballerina.io/learn/by-example/send-email.html
[2] V1.2.x - https://ballerina.io/1.2/learn/by-example/send-and-receive-emails.html

1

There is an email standard library for Ballerina to send and receive emails generically using SMTP and POP3/IMAP respectively. Adding to Suhan's answer, [1] is the API of the email module. You can also find the unit tests written for the email module (for master branch) in [2].

[1] https://ballerina.io/learn/api-docs/ballerina/#/ballerina/email/latest/email/

[2] https://github.com/ballerina-platform/module-ballerina-email/tree/master/email-ballerina/tests

Maninda
  • 2,086
  • 3
  • 15
  • 29