Closed prdanelli closed 4 years ago
Hey @prwhitehead. Please see this discussion regarding this issue https://github.com/ryanb/letter_opener/issues/117. Hope it'll work for you!
Hey @nashby, Thank you for getting back to me.
Unfortunately, the recommendations in the thread you linked are to toggle the perform_deliveries
flag, which then prevents all emails being sent so nothing shows up in Letter Opener.
config.action_mailer.perform_deliveries = false
The point I am trying to get to is where emails are sent by my app, they are caught by letter opener and available for me to see in the interface, but that the Launchy
app isn't triggered to automatically open a new browser tab to present the new email.
Is this possible?
Thank you for your time, Paul.
@prwhitehead hey! Yeah, I think you can do it by simply setting ENV variable LAUNCHY_DRY_RUN=true
. In this case Launchy will just output the command to stdout.
Hello @nashby, thank you for your response. Unfortunately, that didn't work. I am still getting the following error:
WARN: Launchy::CommandNotFoundError: Unable to find a browser command. If this is unexpected, Please rerun with environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at https://github.com/copiousfreetime/launchy/issues/new
sidekiq_1 | 2020-03-15T14:35:33.839Z pid=904 tid=gp9z4tfl8 WARN: /usr/local/rvm/gems/ruby-2.6.5/gems/launchy-2.4.3/lib/launchy/applications/browser.rb:63:in `browser_cmdline'
sidekiq_1 | /usr/local/rvm/gems/ruby-2.6.5/gems/launchy-2.4.3/lib/launchy/applications/browser.rb:67:in `cmd_and_args'
sidekiq_1 | /usr/local/rvm/gems/ruby-2.6.5/gems/launchy-2.4.3/lib/launchy/applications/browser.rb:78:in `open'
sidekiq_1 | /usr/local/rvm/gems/ruby-2.6.5/gems/launchy-2.4.3/lib/launchy.rb:29:in `open'
sidekiq_1 | /usr/local/rvm/gems/ruby-2.6.5/gems/letter_opener-1.7.0/lib/letter_opener/delivery_method.rb:24:in `deliver!'
I confirmed that the ENV variable LAUNCHY_DRY_RUN
was present by logging into the console and outputting the hash.
I did some googling and saw that another project seems to catch the error by monkey patching your delivery!
method: https://github.com/fgrehm/letter_opener_web/blob/master/lib/letter_opener_web/delivery_method.rb
I would prefer not to monkey patch as it means future updates and bug fixes might be missed, but is this something that you would consider adding, in order to help users that are using docker for their apps - an increasing segment of the community i'm sure.
Thank you again for your help with this. Paul.
@prwhitehead Hey! Right, so as I can see Launchy just can't find any browser since you don't have any in your docker env. Could you please try to set BROWSER
env to something like /dev/null
(together with LAUNCHY_DRY_RUN=true
)
OMG YES!
Thanks @nashby, thats working now. I get the following results:
sidekiq_1 | /dev/null file:////home/app/tmp/letter_opener/1584435709_1540718_673e21b/rich.html
sidekiq_1 | 2020-03-17T09:01:49.209Z pid=11 tid=gn1p1909v class=ActionMailer::MailDeliveryJob jid=7e439b8e0f7e89bebcddc8e8 elapsed=8.851 INFO: done
If I made a PR to edit the readme would you accept that, as it might be helpful for others as more move to dockerize their apps?
@prwhitehead awesome! Good idea about PR, go ahead, thanks!
BROWSER=/dev/null LAUNCHY_DRY_RUN=true rails db:seed
worked for me as well on a Rails 6 application without Docker.
Since I have an env var DOCKER_RUNNING
, I can actually use something like:
config.action_mailer.delivery_method = ENV['DOCKER_RUNNING'].present? ? :letter_opener_web :letter_opener
Hello,
First of all, thank you for the Gem, its super useful.
I am trying to move an app to Docker, but LetterOpener doesn't seem to want to let me disable Launchy. I've added an initializer as the docs recommend, trying to just
nil
theLaunchy.application
however that didn't seem to have any effect.I had a look through the code and couldn't see any way to disable it within the Gem, so I was wondering if you might consider adding a flag to disable that part of it. The ability to catch emails in development is amazing, but launching a web browser/tab is something that i'd love to suppress - and instead just view the email inside of the web interface.
As you can see from the error below, my Sidekiq container is trying to send the email via ActionMailer but a
Launchy::CommandNotFoundError
error is being thrown.