Superface

Send Email

communication/send-email@2.2.0
3 providers

Send Email

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

Input
From
To
Subject
Text
HTML
Reply-To
Attachments
Result
Message Identifier

1.Choose a provider

2.Use SendEmail with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('communication/send-email@2.2.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.
replyTo
The Reply-To email address.
attachments
The email attachments.
content
The Base64 encoded content of the attachment.
type
The MIME type of the content you are attaching (e.g., “text/plain” or “text/html”).
filename
The attachment's filename.

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