adonisjs / mail

AdonisJS Email Provider
MIT License
106 stars 34 forks source link

Add FileDriver to write emails to filesystem #86

Closed mattstrayer closed 1 year ago

mattstrayer commented 1 year ago

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

thetutlage commented 1 year ago

Is there any specific use case the file driver will serve?

mattstrayer commented 1 year ago

@thetutlage it is very helpful during development. Writing emails to the file system allows for easy inspection of the rendered html & all relevant message info. The idea was inspired by Django. https://docs.djangoproject.com/en/4.1/topics/email/#obtaining-an-instance-of-an-email-backend

image

Here's an example of how I use it in my basemailer class

public mailer = Application.inDev ? Mail.use('file') : Mail.use('smtp')

thetutlage commented 1 year ago

If this is solely for development, then I highly recommend looking into Mailhog. https://github.com/mailhog/MailHog.

You just have to use Mailhog SMTP credentials and then view emails in their browser based email client. This way, you can not only view the text of the email, but also the attachments or embedded images.

mattstrayer commented 1 year ago

@thetutlage

Totally agree that MailHog is a great tool to have in the tool belt. I also think that there's a place for the file driver to coexist. It is nice to have a solution to see that an email is being sent and the contents of that email without having to rely on any third party services being installed or running.

Julien-R44 commented 1 year ago

Thanks for your PR ! but after talking about it together none of us would use it. We use Mailhog / mailpit all the time so we don't feel like integrating it into the repo because it would mean maintaining a piece of code that we don't use