django-anymail icon indicating copy to clipboard operation
django-anymail copied to clipboard

Feature request: Mailtrap

Open eriktelepovsky opened this issue 1 year ago • 5 comments

Hello. Do you plan to add Mailtrap as a supported ESP?

https://mailtrap.io/

eriktelepovsky avatar Dec 14 '23 22:12 eriktelepovsky

Mailtrap looks like a good fit for Anymail: it has a transactional sending API and a free plan that would cover Anymail's weekly integration testing.

Others who are interested, please express support by adding a thumbs up reaction to the first comment in this issue.

Note that you should already be able to send messages with Mailtrap from your Django app: just configure Django's SMTP EmailBackend to use Mailtrap's SMTP service.

PR welcome. (Or I'll get to this at some point, but it's not likely to be in the next few months.)

For mapping Mailtrap to Anymail features: it looks like Mailtrap provides status tracking webhooks, metadata ("custom variables"), a single tag ("category"), and ESP-stored templates (~~though their API docs don't currently cover sending with a template~~ Edit: docs for sending "EmailWithTemplate" are hidden behind a popup labelled "EmailWithText (one of)").

Mailtrap doesn't currently seem to offer inbound email support, deferred sending, or the ability to control open and click tracking on individual messages.

medmunds avatar Dec 20 '23 19:12 medmunds

Hi @medmunds It also would be awesome to support Mailtrap "Email Testing" (mailtrap initially is mail testing suite, and recently launched an "Email Sending" service) For example, on production I using AWS SES, but for development and staging purposes I use Mailtrap as mail catch-all/testing service.

rez0n avatar Jan 18 '24 03:01 rez0n

Hey @rez0n, if I'm understanding correctly, Mailtrap's email testing feature provides a fake SMTP server that captures sent emails. So you'd just supply those SMTP credentials to Django's built-in SMTP EmailBackend (links in the earlier comment)—there's not really a need for an Anymail backend for that.

It looks like Mailtrap has recently introduced an "early access" HTTP API for sending to test mailboxes, and that could be supported by an Anymail backend. Their docs note it's likely to change, but currently the test API matches Mailtrap's regular email send API payload, except it doesn't support templates. It should be relatively easy to add support for this in Anymail at the same time as regular sending. [If anyone from Mailtrap sees this comment, it would be even easier if the test inbox id could be an API payload field, rather than part of the API endpoint url.]

medmunds avatar Jan 19 '24 20:01 medmunds

Hi @medmunds

if I'm understanding correctly, Mailtrap's email testing feature provides a fake SMTP server that captures sent emails. So you'd just supply those SMTP credentials to Django's built-in SMTP EmailBackend (links in the earlier comment)—there's not really a need for an Anymail backend for that.

This is literally what I do.

It looks like Mailtrap has recently introduced an "early access" HTTP API for sending to test mailboxes, and that could be supported by an Anymail backend. Their docs note it's likely to change, but currently the test API matches Mailtrap's regular email send API payload, except it doesn't support templates. It should be relatively easy to add support for this in Anymail at the same time as regular sending. [If anyone from Mailtrap sees this comment, it would be even easier if the test inbox id could be an API payload field, rather than part of the API endpoint url.]

Sounds very good because in current setup I have different logic of emailing backend on dev(mailtrap via SMTP) and prod (SES via anymail) which is not cool in my opinion.

Thank you for this awesome project, looking forward.

rez0n avatar Jan 31 '24 14:01 rez0n