Connecting Eclipse Dirigible with SendGrid SMTP Relay
Recent changes in Gmail's policies allows Eclipse Dirigible users to send emails only via Workspace enabled accounts in G Suite and require workspace administration privileges. By connecting Eclipse Dirigible with Twilio SendGrid's SMTP Relay feature you can send emails with your personal gmail account.
Note
SendGrid is a 3rd party service and charges/limits apply. Here you can find more information about their Email API Plans.
Setup SendGrid Account
- Create a SendGrid account at https://sendgrid.com.
- Login at https://app.sendgrid.com.
-
Verify a single sender email:
- Click Settings → Sender Authentication → Verify a Single Sender.
- Enter the details of the email address that Eclipse Dirigible mails will be sent from.
-
Setup SMTP Relay:
- Click Email API → Integration Guide → SMTP Relay.
- Enter an API Key Name and click Create Key to get an API Key for your SendGrid SMTP Relay.
- Notice the Configure your application section, the credentials from it will be used to configure the mail client.
Setup Eclipse Dirigible
Prerequisites
You can follow the Setup guide on how to deploy Eclipse Dirigible locally or in the cloud.
-
Add the following environment variables to your deployment:
DIRIGIBLE_MAIL_USERNAME=apikey DIRIGIBLE_MAIL_PASSWORD=<YOUR_API_KEY_HERE> DIRIGIBLE_MAIL_TRANSPORT_PROTOCOL=smtps DIRIGIBLE_MAIL_SMTPS_HOST=smtp.sendgrid.net DIRIGIBLE_MAIL_SMTPS_PORT=465
Note
Replace the
<YOUR_API_KEY_HERE>
placeholder with the SendGrid SMTP Relay API key. -
Restart the Eclipse Dirigible instance in order to apply the new environment variables.
Environment Variables
To get a complete list of all environment variables navigate to the Environment Variables page.
Send an Email with SendGrid SMTP Relay
- Login to your Eclipse Dirigible instance.
- Create new project.
- Create new
Javascript ESM Service
. -
Use the following sinippet to send emails:
import { client as mail } from "sdk/mail"; const from = "<YOUR_VERIFIED_SENDER_EMAIL_HERE>"; const to = "<YOUR_RECIPIENT_EMAIL_HERE>"; const subject = "Subject"; const content = "Hello World!"; const subType = "html"; mail.send(from, to, subject, content, subType);
Note
Replace the
<YOUR_VERIFIED_SENDER_EMAIL_HERE>
and the<YOUR_RECIPIENT_EMAIL_HERE>
placeholders with valid email addresses.