ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.73k stars 238 forks source link

Not opening mail in browser #71

Closed Adrian2112 closed 11 years ago

Adrian2112 commented 11 years ago

I set up letter_opener in my rails project, but when delivering the email it didn't open in the browser as it used to do. I have used letter_opener before, but this time wasn't working.

The problem was that Launchy could not open the file. I was getting this error

Launchy::ApplicationNotFoundError: No application found to handle '/Users/adrian/Icalia%20Labs/tmp/letter_opener/1368036004_b89703f/rich.html'

I tried it in the console using the direct path for the file and it was working without the URI.escape(filepath) but when I tried escaping the filepath I got the same error. Adding file:// solves it. Maybe is an error with Launchy.

I checked out the code and saw that this line in file lib/letter_opener/delivery_method.rb has been changing on and off adding the file:// part

Launchy.open(URI.parse(URI.escape(messages.first.filepath)).to_s)

My question is, why did you decide to remove file:// part? Does anybody have the same issue? I made a fork and reverting to add the file:// worked for me.

nashby commented 11 years ago

@Adrian2112 what version of letter_opener and launchy are you using?

Adrian2112 commented 11 years ago

rails (= 3.2.13) letter_opener (1.1.0) launchy (2.2.0)

nashby commented 11 years ago

@Adrian2112 well, for some reason launchy doesn't like %20 in your path...I have to think about it.

Adrian2112 commented 11 years ago

yes, the thing is that the path actually is /Users/adrian/Icalia Labs/tmp/letter_opener/1368036004_b89703f/rich.html but when it goes through URI.escape() it changes the space to the %20 I think that is the problem, but as I said, it works if I prepend file:// to the escaped filepath

nashby commented 11 years ago

@Adrian2112 OK, I think we have to return file://. Could you please send a pull request?

Adrian2112 commented 11 years ago

sure

nashby commented 11 years ago

@Adrian2112 thank you.

nashby commented 11 years ago

@Adrian2112 I'm going to release a new version so could you please test master branch and report back if it's all ok?

Adrian2112 commented 11 years ago

It's working :+1: