chj915
chj915

Reputation: 37

Ballerina: How do connect with SMTP server and send email?

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?

Upvotes: 3

Views: 229

Answers (2)

Maninda
Maninda

Reputation: 2216

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

Upvotes: 1

Suhan Dharmasuriya
Suhan Dharmasuriya

Reputation: 303

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

Upvotes: 1

Related Questions