Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mailcatcher docker image for development #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ThomAille
Copy link

Added mailcatcher to allow developers to test sending and integrating emails in development

@nickjj
Copy link
Owner

nickjj commented Aug 19, 2022

Hi,

I appreciate the PR and contribution but sorry no thanks. Rails has built in support for this using https://www.seancdavis.com/posts/preview-emails-in-rails/. It lets you preview any email in a browser without sending out an email. Did you encounter issues using this approach?

@ThomAille
Copy link
Author

Hi
I have not encountered any problem with email preview.
However, the rendering is not faithful to the rendering of an email box. The Rails preview is played in a web browser which is much more permissive than a mailbox.
it is for this reason that I add mailcatcher in addition to my rails project to have a rendering closer to an email client.

@nickjj
Copy link
Owner

nickjj commented Aug 20, 2022

Fair enough, it looks like mailcatcher supports both a web UI and being able to see it in a real mail client.

I'll leave this PR open because I do in general like the idea. Sometimes the Rails mail preview solution is troublesome because you want to see the mail from another user or something tied into a job firing off and you don't want to use a hard coded example.

Let me think about this for a bit if you don't mind.

@ThomAille
Copy link
Author

No problem, I already use this version for my personal projects and I update it when necessary. At the moment I added storybook and web compoments to my project.

https://viewcomponent.org/
https://jonspalmer.github.io/view_component_storybook/
https://storybook.js.org/

@nickjj
Copy link
Owner

nickjj commented May 3, 2023

In case anyone is curious, I have been using MailCatcher for about 6 months and it's really good. I ended up making a blog post and video about it here: https://nickjanetakis.com/blog/self-host-and-preview-emails-locally-with-mailcatcher-open-source

I think it'll make its way into this project at some point. Thanks for introducing it to me ThomAille!

@Birdie0
Copy link

Birdie0 commented Jul 22, 2023

What's about using letter_opener_web gem instead?
Previously I was using mailcatcher too, but it was complicating setup a bit as it needed to be running on background beforehand.

The setup of letter_opener_web is pretty straightforward:

  • add mount LetterOpenerWeb::Engine => '/letter_opener' if Rails.env.development? to routes.rb
  • set config.action_mailer.delivery_method = :letter_opener_web in development.rb

All new letters ever sent will be available on the dashboard at http://localhost:3000/letter_opener

Emails data will be stored locally at tmp/letter_opener (can be configured).

UPD: mailpit can be considered as quite good alternative and it provides some nice features like email client compatibility stats.

@nickjj
Copy link
Owner

nickjj commented Jul 22, 2023

I mainly prefer it because it works with any tech stack. It's also decoupled from Rails which makes it a bit more compatible with your app. For example Letter Opener hasn't had a commit in 1.5+ years, if it stops working with the next version of Rails we'd have to wait for a patch. With MailCatcher it will work no matter what version of Rails you have.

Also with Docker it becomes a service you can add to your docker-compose.yml file and not think about it again. In development it gets run with the rest of your services. Thanks to Docker Compose profiles you can also choose not to run it by setting a single env var.

Ultimately both do similar things, feel free to stick with Letter Opener if you prefer it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants