Closed otezz closed 1 year ago
Hi @otezz. Whilst this is an interesting idea, this is unfortunately far too out-of-scope for Mailpit, which is fundamentally an SMTP testing tool (with a fancy UI to view the emails, plus related tools).
It is also not as simple as just those 5 array fields - emails are (or at least can be) constructed with far more than just those fileds. Take a look at this to get some idea of the complexity an API like this should have to handle mime parts, headers, attachments etc. An API like this would not only need to handle the input of all those fields & data types, but also need to construct an email with the data in order to be rendered. Even if I was to spend weeks/months building something like this, then I would also get requests for similar endpoints to mimic MailChannels, SendGrid, SES, Mailgun APIs etc - the list wouldn't end (there are hundreds).
If you really needed a solution like this, then you could build a "bridge" - a custom API that does what you want, which then constructs the email and sends it via SMTP (eg: to Mailpit). it would however need to run as a separate service on a separate port, though that shouldn't be an issue. I this it may be easier for you to just work out how to get SMTP running via Cloudflare Workers, as from what I can see the environment is just NodeJS?
I am currently building an app with Cloudflare Workers and just figure out I am unable to use nodemailer as it is not compatible to run on Cloudflare Workers making me unable to send email via SMTP. There's no issue for production since I will be using API based mail service like MailChannels, SendGrid or SES, but for local development, I'm unable to test my email since mailpit only support sending email via SMTP.
What I'm imagining currently is an endpoint (
POST /mail
) that accept payload bodyAnd then I will be able to review the email on the mailpit web UI
Thank you