Mailtrap Email API/SMTP - API integration
Use API credentials to integrate Mailtrap Email API/SMTP into your project. For SMTP integration, refer to this article.
- 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.
- Open the Integration tab.
- Click the Integrate button under Transactional Stream or Bulk Stream.
- Transactional Stream is used to send automated, non-promotional application emails triggered by the specific user action.
- Bulk Stream is used to send a single marketing campaign to a large group of recipients in bulk.
- Toggle the switch to API.
- 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 menu under Code Samples and copy the sample configuration already containing your credentials. In this menu, you’ll find official SDKs for PHP, Python, Ruby, and Node.js.
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.
- 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 and going to the Integration tab.
You can also create additional API tokens by going to Settings → API 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.