SES Class

Send an email.

Instance Methods

Name Description
public constructor() Constructs a SES client object.
Parameters:
  • options.apiVersion: string
    API version in YYYYY-MM-DD format (or date). Specify 'latest' to use the latest possible version. The default is 'latest'.
  • options.region: string
    The region to send service requests to.
  • options.accessKeyId: string
    AWS access key ID.
  • options.secretAccessKey: string
    AWS secret access key.
import * as sweet from 'express-sweet';

const client = new sweet.services.AWSSesClient({
  apiVersion: 'API Version ("YYYYY-MM-DD" or "latest")',
  region: 'the region to send service requests to',
  accessKeyId: 'your AWS access key ID',
  secretAccessKey: 'your AWS secret access key',
});
const sweet = require('express-sweet');

const client = new sweet.services.AWSSesClient({
  apiVersion: 'API Version ("YYYYY-MM-DD" or "latest")',
  region: 'the region to send service requests to',
  accessKeyId: 'your AWS access key ID',
  secretAccessKey: 'your AWS secret access key',
});
public send() Send email.
Parameters:
  • type: 'text'|'html'
    E-Mail type ('html': HTML mail, 'text': text mail). Default is 'text'.
Return:
  • Promise<string> Unique ID assigned by Amazon SES for a successfully sent email.
import * as sweet from 'express-sweet';

const client = new sweet.services.AWSSesClient({
  apiVersion: 'API Version ("YYYYY-MM-DD" or "latest")',
  region: 'the region to send service requests to',
  accessKeyId: 'your AWS access key ID',
  secretAccessKey: 'your AWS secret access key',
});

// Send email.
await client
  .from('from@example.com', 'Sender Name')
  .to('to@example.com')
  .subject('Test email') 
  .body('Hi, this is a test email')
  .send();

// Use variables in the body of the e-mail.
// The body can use the handlebars and handlebars-extd syntax.
await client
  .from('from@example.com', 'Sender Name')
  .to('to@example.com')
  .subject('Test email') 
  .body('Hello ', {name: 'Mason'})
  .send();
const sweet = require('express-sweet');

const client = new sweet.services.AWSSesClient({
  apiVersion: 'API Version ("YYYYY-MM-DD" or "latest")',
  region: 'the region to send service requests to',
  accessKeyId: 'your AWS access key ID',
  secretAccessKey: 'your AWS secret access key',
});

// Send email.
await client
  .from('from@example.com', 'Sender Name')
  .to('to@example.com')
  .subject('Test email') 
  .body('Hi, this is a test email')
  .send();

// Use variables in the body of the e-mail.
// The body can use the handlebars and handlebars-extd syntax.
await client
  .from('from@example.com', 'Sender Name')
  .to('to@example.com')
  .subject('Test email') 
  .body('Hello ', {name: 'Mason'})
  .send();
public from() Set the sender's email address.
Parameters:
  • from: string
    Sender's email address.
  • name?: string
    Sender Name.
Return:
  • AWSSesClient
public to() Set the destination email address.
Parameters:
  • to: string|string[]
    Email address to be sent to.
Return:
  • AWSSesClient
public cc() Set CC email address.
Parameters:
  • cc: string|string[]
    CC email address.
Return:
  • AWSSesClient
public subject() Set the email subject.
Parameters:
  • subject: string
    Email Subject.
Return:
  • AWSSesClient
public body() Set the body of the email.
Parameters:
  • body: string
    Email Body. The body can use the handlebars and handlebars-extd syntax.
  • vars: {[key: string]: any}
    The value of a variable in the body of the e-mail.
Return:
  • AWSSesClient