Email Capture

Email Capture is a fake SMTP relay service you can send to, where Mailsac captures all the messages.

Email messages sent using Email Capture will not be delivered to the To recipients but instead will be available by looking up the To recipient via the Mailsac website or Mailsac API.

By default, captured emails are public. To keep captured mail private, toggle the Make Captured Email Private option in your account settings. This will “star” captured messages.

Sending Using Email Capture

To configure applications to use Email Capture replace existing SMTP configuration with these settings.

Server Name:

capture.mailsac.com

Port:

5587

Use Secure Connection:

Yes (TLS)

User Authentication:

Yes (Username: Mailsac username Password: Mailsac: API key)

Some SMTP libraries or clients may not support the use of a username that is different from the From address. In that case, the From address will need to be added as an Enhanced Address or be an address in a Custom Domain. The enhanced address or address in a Custom Domain can then be used with the Mailsac API Key as authentication to the Capture service.

Send email using Email Capture
const nodemailer = require('nodemailer')

const mailsaUserName = 'MAILSAC_USERNAME'
const mailsacAPIKey = 'MAILSAC_API_KEY'

const transporter = nodemailer.createTransport({
  host: 'capture.mailsac.com',
  port: 5587,
  // will use TLS by upgrading later in the connection with STARTTLS
  secure: false,
  auth: {
    user: mailsaUserName,
    pass: mailsacAPIKey
  }
})

transporter.sendMail({
  from: '"Mywebapp Customer Support" no-reply@mywebapp.com',
  to: 'mycustomer@gmail.com',
  subject: 'Password reset',
  text: `Click on the link to reset you password
    https://mywebapp.com/password-reset/PasswordResetToken`
})
  .then(response => {
    console.log('Successfully sent mail', response)
  })
  .catch(err => {
    console.log('Failed sending mail', err)
  })

/*
Successfully sent mail {
  accepted: [ 'mycustomer@gmail.com' ],
  rejected: [],
  envelopeTime: 129,
  messageTime: 136,
  messageSize: 413,
  response: '250 OK : queued as 71jiTaUqliiQRb5xMHxja0gU',
  envelope: { from: 'no-reply@mywebapp.com', to: [ 'mycustomer@gmail.com' ] },
  messageId: '<15574d0b-2a51-d854-5755-e2e1b0d29d4f@mywebapp.com>'
}
*/

Validate Email Was Received

The easiest way to check that an email was received is to use the Mailsac website. Use the “Check the mail!” button on the homepage of the Mailsac website to view the inbox that the email was sent to.

../../_images/check_customer_mail.png

Check any inbox from the Mailsac homepage

Validating an email was received can also be done using any programming language that supports HTTP requests, in combination with the Mailsac API. Code examples for Javascript and Python are provided.

../../_images/mycustomer_at_gmail.png

Validate email was received

Make Captured Email Private

Emails sent via capture.mailsac.com can be automatically starred, which keeps the email private, by enabling the Make Capture Email Private option under Account Settings. Starred messages count towards Message Storage limits.

../../_images/private_captured_email_option.png

Traditional Email Flow

Email traditionally flows from an email client (Mail User Agent - MUA), to a outbound SMTP server (Mail Transfer Agent - MTA), to the receiving SMTP server (also an MTA), then to a Mail Delivery Agent (MDA), which is polled by the email client (MUA) using POP3 or IMAP.

../../_images/email_flow.svg

By Polluks - eigene Arbeit, ArgoUML, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=3645799

Along the way, there are typically several places where authentication and integrity are verified. A sender is typically authenticated when connecting to an outbound SMTP server. The receiving MTA will use SPF records, to validate that the sending MTA is allowed to send the mail, and DKIM records to validate the integrity of the email. Finally, the MUA authenticates against the MDA, typically using a username and password.

Email Capture Flow

In the Email Capture model the Mail User Agent uses Mailsac’s receiving Mail Transfer Agent as the outbound MTA (relay). The Email Capture MTA will accept all mail, regardless of the destination domain.

Considerations

  • All email sent will be public (Unless sent to a custom domain or configured to be private)

  • Each message sent will count as an Operation (Op)

Email Capture Use Cases

Email Capture can be used anytime a system needs to send an email, but the email should not be delivered to the customer.

Email Validation in a Non-Production Environment

Non-production environments of applications often do not send email for fear that non-production systems may send email to customers. Using Email Capture, emails can be sent and verified using customer email addresses, without the customer receiving the email.