Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@dbos-inc/communicator-email-ses
Advanced tools
This is a DBOS communicator for sending email using the Amazon Web Services Simple Email Service.
In order to send emails with SES, it is necessary to:
First, ensure that the DBOS SES communicator is installed into the application:
npm install --save @dbos-inc/communicator-email-ses
Second, ensure that the communicator is imported into the relevant source file(s):
import { SendEmailCommunicator } from "@dbos-inc/communicator-email-ses";
Third, place appropriate configuration into the dbos-config.yaml
file; the following example will pull the AWS information from the environment:
application:
aws_ses_configuration: aws_config # Optional if the section is called `aws_config`
aws_config:
aws_region: ${AWS_REGION}
aws_access_key_id: ${AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
If a different configuration file section should be used for SES, the aws_ses_configuration
can be changed to indicate a configuration section for use with SES. If multiple configurations are to be used, the application code will have to name and configure them.
For more information about configuring AWS services, see AWS Configuration.
SendEmailCommunicator
is a configured class. This means that the configuration (or config file key name) must be provided when a class instance is created. One instance per configuration should be created with configureInstance
when the application code starts. For example:
import { configureInstance } from "@dbos-inc/dbos-sdk";
// This will use the dbos-config.yaml section named by `aws_ses_configuration` if it is specified, or `aws_config` if not
const defaultSES = configureInstance(SendEmailCommunicator, 'default');
// This will use the section named `aws_config_marketing`
const marketingSES = configureInstance(SendEmailCommunicator, 'marketing', {awscfgname: 'aws_config_marketing'});
Within a DBOS Transact Workflow, invoke the SendEmailCommunicator
function from the workflow context:
const result = await workflowContext.invoke(defaultSES).sendEmail(
{
to: [workflowContext.getConfig('ses_to_address', 'dbos@nowhere.dev')],
from: workflowContext.getConfig('ses_from_address', 'info@dbos.dev'),
subject: 'Test email from DBOS',
bodyText: 'Check mailbox to see if it worked.'
}
);
Sending a templated email is slightly more involved, as a template must be set up first. Setting up a template can be invoked as a communicator, or directly (so that it can be called from initialization, or other contexts where a workflow may not be in progress).
workflowContext.invoke(defaultSES).createEmailTemplate(...)
or `SendEmailCommunicator.createEmailTemplateFunction(...) to create the template. await workflowContext.invokeOnConfg(defaultSES).createEmailTemplate(
"testTemplate", {subject: "Email using test template", bodyText: "Today's date is {{todaydate}}."}
);
await workflowContext.invoke(defaultSES).sendTemplatedEmail({
to: [workflowContext.getConfig('ses_to_address', 'dbos@nowhere.dev')],
from: workflowContext.getConfig('ses_from_address', 'info@dbos.dev'),
templateName: "testTemplate",
templateDataJSON: JSON.stringify({todaydate: new Date().toISOString()}),
});
The ses.test.ts
file included in the source repository can be used to send an email and a templated email. Before running, set the following environment variables:
SES_FROM_ADDRESS
: An email address within a verified SES sending domainSES_TO_ADDRESS
: Destination email address (which must first be verified with SES if in sandbox mode)AWS_REGION
: AWS region to useAWS_ACCESS_KEY_ID
: The access key with permission to use the SES serviceAWS_SECRET_ACCESS_KEY
: The secret access key corresponding to AWS_ACCESS_KEY_ID
While some email services allow setting of a Message-ID
, which would form the foundation of an idempotent email send, SES does not. This communicator may send duplicate emails in the case of a poorly-timed network or server failure.
FAQs
DBOS library - email in AWS with SES
We found that @dbos-inc/communicator-email-ses demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.