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
- Classes
- Interfaces
- Structs
Email (preflight class)
No description
Constructor
new(props: EmailProps): Email
Properties
No properties
Methods
Signature | Description |
---|---|
inflight send(options: SendEmailOptions): void | No description |
IEmail (interface)
No description
Properties
No properties
Methods
Signature | Description |
---|---|
inflight send(options: SendEmailOptions): void | Sends a simple email. |
EmailProps (struct)
No description
Properties
Name | Type | Description |
---|---|---|
sender | str | The email address for the sender of all emails. |
SendEmailOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
html | str? | The body of the email, in HTML. @default - The text body will be used as the HTML body. |
subject | str | The subject of the email. |
text | str | The body of the email, in plain text. |
to |
| The email addresses to send the email to. |