I have a bunch of ActionMailer emails that are causing some of our users to hit a "Unsafe website" error message in their browser.
In my production.rb I have this line
config.action_mailer.default_url_options = {host: 'app.mybeautifulapp.com', protocol: 'https'}
However, the link that users are receiving in their emails look like this
http://url9522.mybeautifulapp.com/ls/click?upn=CAp2S4s83QBSYKFZSCk5WwfWNUsqJYF6px5T-2BOuGToTGZ8t9qB4P4BTaKBZqlk2vVoJVe9xuVz2PSMMTc7S2AutaZ6j0v5W1XCh75hyix90-3DJuxV_ZtyLTlYa78bQffWNrIlGC7tg8tsMt2Men5eX6g6gxS5tsHKfqDtf3RkdzuylrapUrcYdz5qdOo197RxRznJbD3B9yvPNOfWqgC-2Bh4wL2NohNLpvcJqZw-2FGgQ6LY3XiK3YJIsSWupLZw4LZVPpoJ1fOqV6ugSpk5j8jFmtwCRrxv4UdNgdxksxB6MPGA3NgdMRRNqT1Rla6sBuPyKnZW5thuGtYx4LBqkenbIwTvRMM0-3D
Both the subdomain and the protocol are being ignored. Any way I can fix this?
Related
I have a rails 5 app that sends emails using Sendgrid. Those emails have links back into the app, such as <%= link_to "Reply on platform", conversation_url(#conversation) %>.
This all worked fine and dandy, until I added my SSL cert to the site. Now, all of the mailer links point to https://domain.com, instead of simply domain.com. When visiting https://domain.com, the site fails to load and throws an error saying "This site can’t be reached".
This is probably a simply fix that's right under my nose, but I'm having trouble putting my finger on it. Any advice?
Check your mailer configuration in production at config/environments/production.rb.
Make sure you have or add a line that says:
config.action_mailer.default_url_options = {host: "www.domain.com"}
Why does the test environment need default_url_options be set for ActionMailer?
If I don't set it, I'm getting this when executing my specs:
ActionView::Template::Error:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
I'm especially wondering because when setting
config.action_mailer.default_url_options = {host: 'localhost:3000'}
then in theory links in emails will lead to localhost:3000, which as far as I know is not where the test server instance really is running? Still, when using email_spec gem and clicking on links in emails, they work, because the gem removes the server name and port, so a link typically looks like this:
/en/user/confirmation?confirmation_token=QZu3tw17uozhpEfuVWzF
So one more time: what do I need to specify the host for if it's removed by email_spec gem anyway?
You need it because you are generating URLs in your email and ActionMailer needs the :host to know how to properly build the URL. The fact that email_spec removes it later on is irrelevant.
I'm sure this question has been asked before, but I can't seem to find it. My devise sign up system was working fine yesterday; the emails were being sent, and clicking on the confirmation link in the email confirmed the account and redirected the user to the home page.
Today, the email still sends, but when I click on the confirmation link, I get the error message that "this webpage is not available," and the account isn't confirmed.
I recently switched from a vagrant virtual machine to nitrous.io, so this issue may have something to do with that . . . the url for my local version of my app isn't localhost:3000 anymore, and that's still what it says in the confirmation link. But the devise code doesn't specify localhost:3000, it specifies #resource. Since I don't have devise controllers, I don't know exactly what #resource refers to . . .
I realize this isn't much information, but I'm not sure what else to include. Does anyone have any ideas for me?
Thanks!
I'm guessing the link is directing you to rails server in development at localhost:3000. Change (or add) it in config/environments/development.rb .
config.action_mailer.default_url_options = { host: ..... } # eg. { host: 'localhost:3000' }
Your development.rb file needs to point to your hosted environment. So:
config.action_mailer.default_url_options = { host: 'http://something-yada.use1.nitrousbox.com }
That should take care of your issue. Remember localhost points to your local machine whereas Nitrous is a hosted environment.
I have been unable to get Spree to send a copy of an order confirmation email after an order is placed. The customer gets the order confirmation however. I can intercept the order confirmation email as well. I have added my email in the Spree Admin "Send Copy of all mails to", as well as having tried adding config.mail_bcc = "contact#mydomain.com" in the config/initializers/spree.rb. I checked the params when I update the Admin, and it does correctly send the mail_bcc = 'contact#mydomain.com'. Any thoughts?
Spree 2.0 has some e-mail settings in the admin area which are a bit problematic. I generally recommend setting:
# config/initializers/spree.rb
Spree.config do |config|
config.override_actionmailer_config = false
end
This will allow you to use the default ActionMailer configuration. Without this setting, Spree will use its own code to handle mail configuration through the admin area.
For more information see:
Spree Deployment Tips
Example ActionMailer Configuration
I want to embed a link to an article in a mail send by ActionMailer.
For that, I just want to place the absolute URL to and article in a plain text email.
I am using the following line of code in the view.
<%= article_url(#article) %>
It works correctly on my development machine, i.e. I get http://localhost:3000/articles/14 for some article with ID=14.
But when I deploy to Heroku as production site, it localhost:3000 is not replaced with the URL of my production site. Do I need to configure that somewhere? Any hints? Thanks!
I am using Rails 3.
See this option in your_app/config/environments/production.rb:
config.action_mailer.default_url_options = { :host => 'your-domain.heroku.com' }