Closed patrickberkeley closed 12 years ago
That is strange, which version of Ruby and Rails are you using?
Also, can you try running ls tmp/letter_opener
to see if the files are being generated? Maybe Launchy is just having trouble opening the file in the browser.
Looks like I wasn't requiring Launchy properly. Try upgrading to the latest version (0.0.2) and let me know if that fixes it.
Same problem.
Updated to 0.0.2 and still nothing, emails are being saved under tmp/letter_opener. Running on Ruby 1.8.7 and Rails 3.0.3
Can you try running this in the Rails console and see if it opens up the browser?
file = File.expand_path(Dir["tmp/letter_opener/*/plain.html"].first)
Launchy.open("file://#{file}")
The first line should return the path to one of the files.
Tried running just
Launchy.open("#{Rails.root}/tmp/letter_opener/1315440077_de8f984/rich.html")
but got
Unable to launch file:///***/tmp/letter_opener/1315440077_de8f984/rich.html
returning nil
also File.read
worked just fine
Got it.
Launchy::Browser.run made the difference, submitting patch
The files aren't being generated on my machine. tmp/letter_opener
does not exist. Must be missing something...
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
Rails 3.0.9
OS X 10.7.1
Same here. No tmp/letter_opener
dir :(
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin11.1.0], MBARI 0x6770, Ruby Enterprise Edition 2011.03
Rails 3.0.9
Mac OS X 10.7.1
@fedesoria thanks for the patch! I'll pull this in.
@patrickberkeley and @alphaone, just verifying that you changed the delivery method in development and restarted the server? Do you see anything unusual in the log file when an email is sent?
Yes changed the delivery method in development.rb and restarted. Nothing's changed in the log.
For those having trouble with this, would you mind trying out this example app?
http://dl.dropbox.com/u/1415348/letter_opener_example.zip
Just run bundle
and rails s
in there, and visit http://localhost:3000/ will send an email which should open up in the browser. This will help determine if it's something app specific or system specific.
Edit: I just noticed it includes the tmp/letter_opener directory so you may want to remove that when testing. Thanks!
Works! (Even with tmp/letter_opener
removed.) Not sure what to change in my env. What info can I provide that would be helpful?
Are you doing anything out of the ordinary in your mailer? Like attachments or special encodings? I wonder if it's a Rails 3.0.9 vs 3.0.10 problem...
Very odd: When I run UserMailer.test.deliver!
letter_opener creates the right files, but they are empty and I get this error:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.join
from (erb):59:in `render'
from /Library/Ruby/Gems/1.8/gems/letter_opener-0.0.2/lib/letter_opener/message.rb:14:in `render'
from /Library/Ruby/Gems/1.8/gems/letter_opener-0.0.2/lib/letter_opener/message.rb:13:in `open'
from /Library/Ruby/Gems/1.8/gems/letter_opener-0.0.2/lib/letter_opener/message.rb:13:in `render'
from /Library/Ruby/Gems/1.8/gems/letter_opener-0.0.2/lib/letter_opener/delivery_method.rb:11:in `deliver!'
from /Library/Ruby/Gems/1.8/gems/letter_opener-0.0.2/lib/letter_opener/delivery_method.rb:11:in `each'
from /Library/Ruby/Gems/1.8/gems/letter_opener-0.0.2/lib/letter_opener/delivery_method.rb:11:in `deliver!'
from /Library/Ruby/Gems/1.8/gems/mail-2.3.0/lib/mail/message.rb:245:in `deliver!'
from (irb):8
UserMailer.test
is just a stupid method that does nothing but render test.html.erb
with some 'lorem ipsum' in it.
My setup: Mac OS 10.7.1 ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0] Rails 3.1.0 letter_opener 0.0.2
The full list of the gems in the bundle:
Nevertheless: This is an awesome gem and I can't wait to use it on my projects :)
@christophedthofer, I think this is a different issue. I'm guessing the deliver!
call is instantiating the delivery method in a different way than expected. See issue #9 for problems with this method.
For those having an issue with no tmp/letter_opener
directory existing, and no exception raised in the log file, make sure you do not have this line in the development.rb.
config.action_mailer.perform_deliveries = false
Or try adding this to the end.
config.action_mailer.perform_deliveries = true
Is anyone still having issues with Letter Opener not working? If not I will close this issue.
Sorry for the delay here. I hope to get back to this this weekend.
To answer your questions:
I tried removing and setting config.action_mailer.perform_deliveries
but to no avail.
Rails 3.0.9 might be the issue but I'm not to a point where I can upgrade yet.
Hmm, I'll try testing with 3.0.9, thanks for the feedback.
I just tested 3.0.9 and it works for me. Any other ideas on what could be the problem?
I found the problem because of launchy dependency version. Because @ryanb use the new version, but others not.
I just ran into a similar problem where letter_opener creates the tmp/letter_opener/subdir directory structure. And it creates the rich.html file. But the file is 0 bytes.
Setting config.action_mailer.perform_deliveries=true
showed the error:
NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.join):
app/controllers/registrations_controller.rb:16:in `create'
Rendered vendor/ruby/1.9.1/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.9ms)
Rendered vendor/ruby/1.9.1/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4.8ms)
Rendered vendor/ruby/1.9.1/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (10.6ms)
and I realized I'd forgotten to set the default from:
address in my Mailer.
So FYI for future users. I'm going to open this as a new issue and make a fix for it at some point.
I'm also having trouble where letter_opener doesn't create the tmp/letter_opener directory. I tried out the sample app and it worked fine there so it's gotta be something wrong with my app. Anyone else with that problem figure out what was wrong?
Gems included by the bundle:
Hi Ryan,
I tried letter_opener with a rails 3.1 app; running ruby 1.9.2 on an app that sends activation codes to users when registered for the site. When it gets to the deliver option I am getting an Exception saying 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true'
I have followed the set up instructions, but I'm having no joy... I have also tried putting 'config.action_mailer.perform_deliveries = true' as per your instructions above.
I did notice that though letter_opener is installed I didn't have a letter_opener directory in my temp directory.
Very odd
Edit: Added default_url_options line to development.rb and all works ok...
@PaulGis, have you tried to add below line of code into your environments/development.rb
?
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
@samnang, I did yes; and then it started to work :) thanks for the reply
Ubuntu 11.10, rails 3.1.3. Nothing happens :( Files in tmp/letter_opener are empty (0 bytes). wtf?
Got same result as Mr. tipugin: files under tmp/letter_opener are empty (0 bytes). I'm on Linux Mint 12 x64 edition, Ruby 1.8.7 patchlevel 352, Rails 3.2.1.
Same issue using Rails 3.2.1 & Ruby 1.9.3. I'm using Unicorn/DelayedJob in development, and thought that was causing an issue, but now not so sure...
Same here, but only with attachments. Rails 3.2.2, Ruby 1.9.3-p125.
Mail is sent correctly via smtp.
EDIT: [removed comment about mail.body
, was multipart => overtired...]
Anyhow, I tracked it further down: The Problem is here https://github.com/ryanb/letter_opener/blob/master/lib/letter_opener/message.rb#L14
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
thereI have written a fast patch which I have to beautify prior to commiting it. Maybe I'll add the ability to show attachments as well (#26).
In case it helps anyone, make sure that your "from" address is correct. I have just tracked down a bug when emails would be normally sent in production, but letter_opener would not work. The reason ended up to be wrong "from" address.
My "from" address was (mistakenly) just a label, e.g. "Company Name", but it worked fine because source email address (support@company.com) was set up during ActionMailer configuration. Apparently, Rails is happy with that, but not letter_opener. I changed "from" address to "Company Name support@company.com" and it worked as it should.
Hey guys! Could everybody test letter_opener from master branch? Looks like it was a problem with Launchy version and now it depends on >= 2.0.4 and it works ok now (it didn't work with < 2.0.4). So I'm closing this for now. If you other issues feel free to create a new.
I know it's been a month since this issue was closed but I'm just posting here to confirm that it has indeed been fixed. Great work!
@GuilhermeSimoes thank you for letting us know!
My rails version is 3.2.12 on windows7. My project uses mongoid. letter_opener is not working. It doesn't make tmp/letter_opener. And Launchy.open("d:\rails/steam-jm/public/404.html") opens up the browser Please help me.
@sungil could you please create a simple application that reproduces this issue and push it to github?
I found the reason letter_opener was not working. It is not related with letter_opener gem. The letter_opener gem is working well.
@sungil so what was the reason? I'm still having problems on my mac but on other machines (same application) is working.
Hey Guys, Weird thing happening here. Letter Opener creates the e-mail template under tmp however my browser does not display the sent e-mail. I've already tested on Chrome and FF and It doesn't show at all. Any thoughts? I'm using Ubuntu 12.04
@brunomeira hey, what version of launchy
are you using?
@nashby I'm using 2.1.2
@brunomeira looks like you're using pretty old version of letter_opener. Could you please try to update it and report back?
Hi guys,
I'm on ubuntu 14.04 lts and im getting a similar issue. my tmp file has the emails but it dosent open up in new tabs on browser. heres the error i got from the log:
[0417/123858:ERROR:nss_util.cc(94)] Failed to create /home/moeyster/.pki/nssdb directory.
here are my gem versions:
launchy (2.4.3) letter_opener (1.3.0)
tried the code: file = File.expand_path(Dir["tmp/letter_opener/1424839210_a3ea6cb/rich.html"].first) Launchy.open("file://#{file}")
and it works, but when emails are sent through the app, nothing opens in the browser. the emails worked before, and it worked pretty well. untill one day it just stopped. i havent changed anything in the app however i did install an update on my OS. any suggestions?
Hello guys, not sure if I'm just stupid or maybe other people also got problem with this. But I found out that problem with my project is actually not in letter_opener
but in rubymine. Not sure yet how or even possible to fix it.
Otherwise great gem. Keep up the good work!
@looser990 Do you mean if you develop an application with Rubymine, if you run it from Rubymine, ...?
@jgrosso-dynamynd Yes. I'm developing with Rubymine and when I start application in development mode using Rubymine it does not open mails. If I run application from terminal it works as expected.
Hi guys , I have integrated this gem in my application successfully. But the problem is nothing shows up in my browser. Moreover, i cant see any folder ''letter_opener" under tmp directory. The version of gems are as follows:
letter_opener-1.4.1
launchy-2.4.3
One more thing , gem works if I add this line config.action_mailer.perform_deliveries = true
to my development.rb whereas it is not mentioned in the documentation. But still nothing shows up in my browser. What am i missing?
@mhassaan hey, what OS are you using?
I've had this issue using Ruby-2.3.1 and Rails 4.2.3. The only way I could get it to work was adding...
config.action_mailer.default_url_options = { host: ENV["DOMAIN"] }
@nashby I am using OSX El Captain.
I have the same problem, Chrome and OS X El Cap. "perform_deliveries" doesn't help.
I followed the instructions (1. Add the gem to Gemfile, run bundle, 2. Set delivery method to :letter_opener in development.rb) and nothing happens when a mail is sent. I scanned through the logs and it looks normal. Tried this with both pow and normal WEBrick server.
Thanks! This looks awesome.