# 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 sent back to the email address it was originally sent to Mailosaur from. Before you can reply, you must either verify the address as an [external email address](/docs/managing-your-account/external-email-addresses) or verify the [domain name](/docs/managing-your-account/managing-domains) as a whole.
## Replying to a test email
You can reply to emails within the Mailosaur Dashboard, or via the API:
Hello world. Hello world. Hello world. Hello world. Hello world. Hello world. Hello world. Hello world.
Hello world.
', attachments: attachments }); ``` ```cypress const attachments = [{ fileName: 'cat.png', contentType: 'image/png', content: '{BASE64_ENCODED_FILE}' }]; cy.mailosaurReplyToMessage('{MESSAGE_ID}', { html: 'Hello world.
', attachments: attachments }); ``` ```python attachment = Attachment() attachment.file_name = "cat.png" attachment.content_type = "image/png" attachment.content = "{BASE64_ENCODED_FILE}" attachments = [attachment] body = "Hello world.
" options = MessageReplyOptions(html=body, attachments=attachments) mailosaur.messages.reply("{MESSAGE_ID}", options) ``` ```java Attachment attachment = new Attachment(); attachment.withFileName("cat.png"); attachment.withContentType("image/png"); attachment.withContent("{BASE64_ENCODED_FILE}"); MessageReplyOptions options = new MessageReplyOptions(); options.withHtml("Hello world.
") .withAttachments(Arrays.asList(new Attachment[] { attachment })); mailosaur.messages().reply("{MESSAGE_ID}", options); ``` ```csharp var attachment = new Attachment() { FileName = "cat.png", ContentType = "image/png", Content = "{BASE64_ENCODED_FILE}" }; mailosaur.Messages.Reply("{MESSAGE_ID}", new MessageReplyOptions() { Html = "Hello world.
", Attachments = new ListHello world.
' options.attachments = [attachment] mailosaur.messages.reply('{MESSAGE_ID}', options) ``` ```php $attachment = new Attachment((object)[ "fileName" => "cat.png", "contentType" => "image/png", "content" => "{BASE64_ENCODED_FILE}" ]); $options = new MessageReplyOptions(); $options->html = 'Hello world.
'; $options->attachments = [$attachment]; $mailosaur->messages->reply('{MESSAGE_ID}', $options); ``` ```go var attachment = Attachment{ FileName: "cat.png", ContentType: "image/png", Content: "{BASE64_ENCODED_FILE}", } m.Messages.Reply("{MESSAGE_ID}", &MessageReplyOptions{ Html: "Hello world.
", 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: ```nodejs const fs = require('fs'); // ... const buffer = fs.readFileSync('/path/to/file.txt'); const content = buffer.toString('base64'); ``` ```python import base64 # ... file = open('/path/to/file.txt', 'rb') content = base64.b64encode(file.read()).decode('ascii') ``` ```java byte[] data = Files.readAllBytes(Paths.get("file.txt")); String content = new String(Base64.getEncoder().encode(data)); ``` ```csharp var data = File.ReadAllBytes("/path/to/file.txt"); var content = Convert.ToBase64String(data); ``` ```ruby require 'base64' # ... data = File.open('/path/to/file.txt').read content = Base64.encode64(data) ``` ```php $data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'path/to/file.txt'); $content = base64_encode($data); ``` ```go data, _ := ioutil.ReadFile("/path/to/file.txt") content := base64.StdEncoding.EncodeToString(data) ```