Send Email

communication/send-email@2.1.0
Supported by 4 providers
M
M
P
S

Send Email

Send transactional email to one recipient. Email can contain text and/or html representation.

Input
From
To
Subject
Text
HTML
Attachments
Result
Message Identifier

1.Choose a provider

2.Use SendEmail with mock in your code

npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

const sdk = new SuperfaceClient();

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('communication/send-email@2.1.0');

  // Use the profile
  const result = await profile
    .getUseCase('SendEmail')
    .perform({
      from: 'no-reply@example.com',
      to: 'jane.doe@example.com',
      subject: 'Your order has been shipped!',
      text: 'Hello Jane, your recent order on Our Shop has been shipped.',
      attachments: [
        {
          filename: 'order.pdf',
          type: 'application/pdf',
          content: 'JVBERi0xLjQKJeLjz9MKMyAwIG9...'
        }
      ]
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

from
The sender's email address.
to
The recipient's email address.
subject
The subject of your email. See character length requirements according to RFC 2822.
text
The plain text email message.
html
The HTML email message.
attachments
The email attachments.

Example

{
  "from": "no-reply@example.com",
  "to": "jane.doe@example.com",
  "subject": "Your order has been shipped!",
  "text": "Hello Jane, your recent order on Our Shop has been shipped.",
  "attachments": [
    {
      "filename": "order.pdf",
      "type": "application/pdf",
      "content": "JVBERi0xLjQKJeLjz9MKMyAwIG9..."
    }
  ]
}

Result (object)

messageId
The identifier is provider-specific and not unique.

Example

{
  "messageId": "JpITLjVBS3iknTzDq1BKPg"
}

Implementation details

Provider
mock
Use case
SendEmail
Author
@superface
Source
Verified