Skip to main content

Email

Prerequisites​

For AWS, you need to have an AWS account and the AWS CLI installed. You'll also need to have Terraform or OpenTofu installed to deploy the application.

Installation​

npm i @winglibs/email

Usage​

bring email;

let email = new email.Email(sender: "example@example.com");

new cloud.Function(inflight () => {
email.send(
to: ["example@example.com"],
subject: "My subject",
text: "My content",
html: "<h1>My content</h1>", // optional
);
});

Simulator​

When using email.Email in the local simulator, emails are mocked and are emitted to the logs. A table showing all emails that have been sent can be viewed in the email resource's interaction panel.

AWS​

When compiled to AWS platforms, the email resource uses Amazon SES. For testing, we recommend using your own email address for sender since sender email addresses must be verified. When the application is deployed, an email will be sent to verify the configured sender address.

By default, new AWS accounts are in the sandbox mode. This means emails can only be sent to verified addresses. It also limits the number of emails that can be sent. To send emails to other addresses, you need to request production access here.

License​

This library is licensed under the MIT License.​

API Reference​

Table of Contents​

Email (preflight class) ​

No description

Constructor​

new(props: EmailProps): Email

Properties​

No properties

Methods​

SignatureDescription
inflight send(options: SendEmailOptions): voidNo description

IEmail (interface) ​

No description

Properties​

No properties

Methods​

SignatureDescription
inflight send(options: SendEmailOptions): voidSends a simple email.

EmailProps (struct) ​

No description

Properties​

NameTypeDescription
senderstrThe email address for the sender of all emails.

SendEmailOptions (struct) ​

No description

Properties​

NameTypeDescription
htmlstr?The body of the email, in HTML. @default - The text body will be used as the HTML body.
subjectstrThe subject of the email.
textstrThe body of the email, in plain text.
to
Array
The email addresses to send the email to.