If your product is capable of handling inbound emails, you can use Mailosaur’s sending feature to trigger this functionality in your product.
Sending an email to start a test
You can send emails within the Mailosaur Dashboard, or via the API:
- Go to the Servers page in the Mailosaur Dashboard.
- Click on a server.
- Click on New Message 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 (Note: the message body field supports Markdown syntax.)
- 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 emailNext
Testing with POP3