If your product is capable of handling inbound emails, you can use Mailosaur’s sending feature to trigger this functionality in your product.
Before you can send emails, you must first verify an external email address or domain name so that you can send email to it.
Sending an email to start a test
You can send emails within the Mailosaur Dashboard, or via the API:
- In the left-hand navigation, locate the Inboxes section.
- Click on the name of an inbox.
- Click on Compose at the top of the page.
- Select the email address to send to. You can only send to verified external email addresses.
- Enter the subject and message body for the email.
- When you are finished, click Send.
await mailosaur.messages.create('{SERVER_ID}', {
to: 'someone@example.com', // must be a verified address
subject: 'Email from Mailosaur',
html: '<p>Hello world.</p>',
send: true
});Attachments
You can include attachments in emails sent via the API, by including an array of base64-encoded attachment objects:
const attachments = [{
fileName: 'cat.png',
contentType: 'image/png',
content: '{BASE64_ENCODED_FILE}'
}];
await mailosaur.messages.create('{SERVER_ID}', {
to: 'someone@example.com', // must be a verified address
subject: 'Email from Mailosaur',
html: '<p>Hello world.</p>',
send: true,
attachments: attachments
});The content property of an attachment should be the base64-encoded content of the file you want to attach. Here’s an example of how to base64-encode a file:
const fs = require('fs');
// ...
const buffer = fs.readFileSync('/path/to/file.txt');
const content = buffer.toString('base64');Previous
Replying to email