Mailtrap Email Sending API integration

Use API credentials to integrate Mailtrap Email Sending into your project. For SMTP integration, refer to this article

  1. Go to the Sending Domains tab and choose the domain you want to send emails from. Remember that you’ll be able to start sending emails to your recipients once the domain is verified. See domain setup and verification instructions here
  2. Open the SMTP/API Settings tab. There, you’ll see Transactional Stream and Bulk Stream

    • Transactional Stream is used to send automated, non-promotional application emails triggered by the specific user action. To send transactional emails, use the API credentials under the Transactional Stream. 

    • Bulk Stream is used to send a single marketing campaign to a large group of recipients in bulk. To send bulk emails, use the API credentials under the Bulk Stream. 

    • Transactional and Bulk streams have different hosts, so make sure you choose the correct one. 

  1. Build the authenticated HTTP request in your programming language or framework and configure it with Mailtrap host and API token. Alternatively, choose the programming language or framework from the dropdown menu and copy the sample configuration already containing your credentials.  

  1. Mailtrap Email Sending has official SDKs for PHP, Python, Ruby, Node.js, and Elixir. When you select these languages from the dropdown menu, you’ll find an example from the official client and a link to GitHub.

    Note: For now, only Ruby, PHP (Laravel + Symfony), and Node.js SDKs support Bulk Stream, but others are in development. Request and response examples are also available here

  1. Complete your script and run it. If you did everything correctly, you should find the sent email in the inbox of the email address you indicated in the script. The email will also appear in Email Logs in Mailtrap. 

Remember that each domain has different API tokens that you can always access by clicking on the desired domain, going to the SMTP/API Settings tab, and toggling the switch to API. You can also create additional API tokens by going to SettingsAPI Tokens and clicking Add Token. Read more about creating and managing tokens here

Mailtrap Email Sending API supports email templates, attachments, custom variables, and email categories. The API documentation is available here

If you need any help with API integration, please, contact our support team at support@mailtrap.io

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us