Email testingReplying

Replying to email

Use the reply function to simulate a user replying to one of your emails.

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:

  1. Open one of your emails within the Mailosaur Dashboard.
  2. Click the Reply button, at the top of the screen.
  3. Enter the message body for the reply (Note: this field supports Markdown syntax.)
  4. 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>'
});
// MESSAGE_ID: The `id` of the message you want to reply to
cy.mailosaurReplyToMessage('{MESSAGE_ID}', {
  html: '<p>Hello world.</p>'
});
body = "<p>Hello world.</p>"
options = MessageReplyOptions(html=body)

# MESSAGE_ID: The `id` of the message you want to reply to
mailosaur.messages.reply("{MESSAGE_ID}", options)
MessageReplyOptions options = new MessageReplyOptions();
options.withHtml("<p>Hello world.</p>");

// MESSAGE_ID: The `id` of the message you want to reply to
mailosaur.messages().reply("{MESSAGE_ID}", options);
// MESSAGE_ID: The `id` of the message you want to reply to
mailosaur.Messages.Reply("{MESSAGE_ID}", new MessageReplyOptions() {
    Html = "<p>Hello world.</p>"
  }
);
options = Mailosaur::Models::MessageReplyOptions.new()
options.html = '<p>Hello world.</p>'

# MESSAGE_ID: The `id` of the message you want to reply to
mailosaur.messages.reply('{MESSAGE_ID}', options)
$options = new MessageReplyOptions();
$options->html = '<p>Hello world.</p>';

// MESSAGE_ID: The `id` of the message you want to reply to
$mailosaur->messages->reply('{MESSAGE_ID}', $options);
// MESSAGE_ID: The `id` of the message you want to reply to
m.Messages.Reply("{MESSAGE_ID}", &MessageReplyOptions{
  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
});
const attachments = [{
  fileName: 'cat.png',
  contentType: 'image/png',
  content: '{BASE64_ENCODED_FILE}'
}];

cy.mailosaurReplyToMessage('{MESSAGE_ID}', {
  html: '<p>Hello world.</p>',
  attachments: attachments
});
attachment = Attachment()
attachment.file_name = "cat.png"
attachment.content_type = "image/png"
attachment.content = "{BASE64_ENCODED_FILE}"
attachments = [attachment]

body = "<p>Hello world.</p>"
options = MessageReplyOptions(html=body, attachments=attachments)

mailosaur.messages.reply("{MESSAGE_ID}", options)
Attachment attachment = new Attachment();
attachment.withFileName("cat.png");
attachment.withContentType("image/png");
attachment.withContent("{BASE64_ENCODED_FILE}");

MessageReplyOptions options = new MessageReplyOptions();
options.withHtml("<p>Hello world.</p>")
  .withAttachments(Arrays.asList(new Attachment[] { attachment }));

mailosaur.messages().reply("{MESSAGE_ID}", options);
var attachment = new Attachment() {
  FileName = "cat.png",
  ContentType = "image/png",
  Content = "{BASE64_ENCODED_FILE}"
};

mailosaur.Messages.Reply("{MESSAGE_ID}", new MessageReplyOptions() {
    Html = "<p>Hello world.</p>",
    Attachments = new List<Attachment>() { attachment }
  }
);
attachment = Mailosaur::Models::Attachment.new()
attachment.file_name = 'cat.png'
attachment.content_type = 'image/png'
attachment.content = '{BASE64_ENCODED_FILE}'

options = Mailosaur::Models::MessageReplyOptions.new()
options.html = '<p>Hello world.</p>'
options.attachments = [attachment]

mailosaur.messages.reply('{MESSAGE_ID}', options)
$attachment = new Attachment((object)[
  "fileName" => "cat.png",
  "contentType" => "image/png",
  "content" => "{BASE64_ENCODED_FILE}"
]);

$options = new MessageReplyOptions();
$options->html = '<p>Hello world.</p>';
$options->attachments = [$attachment];

$mailosaur->messages->reply('{MESSAGE_ID}', $options);
var attachment = Attachment{
  FileName:    "cat.png",
  ContentType: "image/png",
  Content:     "{BASE64_ENCODED_FILE}",
}

m.Messages.Reply("{MESSAGE_ID}", &MessageReplyOptions{
  Html: "<p>Hello world.</p>",
  Attachments: []Attachment{attachment},
})

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');
import base64

# ...

file = open('/path/to/file.txt', 'rb')
content = base64.b64encode(file.read()).decode('ascii')
byte[] data = Files.readAllBytes(Paths.get("file.txt"));
String content = new String(Base64.getEncoder().encode(data));
var data = File.ReadAllBytes("/path/to/file.txt");
var content = Convert.ToBase64String(data);
require 'base64'

# ...

data = File.open('/path/to/file.txt').read
content = Base64.encode64(data)
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'path/to/file.txt');
$content = base64_encode($data);
data, _ := ioutil.ReadFile("/path/to/file.txt")
content := base64.StdEncoding.EncodeToString(data)