sofn-xyz / mailing

Build, test, send emails with React
https://www.mailing.run
MIT License
3.61k stars 72 forks source link

Open static HTML emails in dev #454

Open psugihara opened 1 year ago

psugihara commented 1 year ago

Problem

Today if your app tries to send an email mailing in development, mailing tries to open it with the preview server. If the preview server is not running, mailing-core spits an error in your app log telling you to boot up the preview server to see emails in dev.

The preview server is very useful for building emails. However, most of your time developing your app is (hopefully) not spend building emails. Making me have mailing open to check that tweaking a web feature will still send my emails is a bit rude.

Proposed solution

If the preview server is not running, mailing-core should just render the email html to a temporary file and open that in your browser. Here's a library that implements a similar strategy: https://www.npmjs.com/package/preview-email

In the future we could also add a banner telling you to use the preview server for editing to make the UX a little more unified.

Big thanks to @m5r for suggesting this.

alexfarrill commented 1 year ago

Good idea! One thing to think about: there are benefits to the current system in that if you don't want to think about how emails are working (e.g. debugging/developing something that sends a lot of emails, but where the email part is working fine), the current system effectively surpresses seeing them. We may need a way to disable emails. I suppose you could run mailing in --quiet mode if you don't want to see emails?