If your product is capable of handling email replies from your customers, you can use Mailosaur’s reply feature to simulate such a scenario.
When you reply, the email is obviously sent back to the email address it was originally sent to Mailosaur from. Before you can reply, you must first add this address as a verified external email address.
Replying to a test email
You can reply to emails within the Mailosaur Dashboard, or via the API:
- Open one of your emails within the Mailosaur Dashboard.
- Click the Reply button, at the top of the screen.
- Enter the message body for the reply (Note: this field supports Markdown syntax.)
- When you are finished, click Send.
// MESSAGE_ID: The `id` of the message you want to reply to
await mailosaur.messages.reply('{MESSAGE_ID}', {
html: '<p>Hello world.</p>'
});
Attachments
You can include attachments in replies requested 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.reply('{MESSAGE_ID}', {
html: '<p>Hello world.</p>',
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');