Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. Missing host to link to! Please provide :host parameter or set default_url_options[:host]
  2.  
  3. config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  4.  
  5. config.action_mailer.default_url_options = { :host => 'mywebsitename.com' }
  6. config.action_mailer.default_url_options = { :host => 'heroku.mywebsitename.com' }
  7.  
  8. config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }
  9.  
  10. User.create(:username => "test", :email => "test@test.com", :password => "test1234", :password_confirmation => "test1234", :confirmed_at => "2010-11-03 14:11:15.520128")
  11.  
  12. ActionView::Template::Error: Missing host to link to! Please provide :host parameter or set default_url_options[:host]
  13. /home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/route_set.rb:473:in `url_for'
  14. /home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/url_for.rb:132:in `url_for'
  15. /home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_view/helpers/url_helper.rb:99:in `url_for'
  16. /home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/route_set.rb:195:in `user_confirmation_url'
  17.  
  18. config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }
  19.  
  20. Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
  21. /usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in `initialize'
  22. /usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in `open'
  23. /usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
  24. /usr/ruby1.8.7/lib/ruby/1.8/timeout.rb:62:in `timeout'
  25.  
  26. config.action_mailer.default_url_options = { :host => 'localhost' }
  27.  
  28. config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }
  29.  
  30. heroku addons:add sendgrid:free
  31.  
  32. config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  33.  
  34. config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }
  35.  
  36. config.action_mailer.default_url_options = { :host => ENV['MAILER_URL'] }
  37.  
  38. heroku config:set MAILER_URL=my-awesome-app.herokuapp.com --app my-awesome-app
  39.  
  40. ActionMailer::Base.smtp_settings = {
  41. :address => 'smtp.sendgrid.net',
  42. :port => '587',
  43. :authentication => :plain,
  44. :user_name => ENV['SENDGRID_USERNAME'],
  45. :password => ENV['SENDGRID_PASSWORD'],
  46. :domain => 'heroku.com'
  47. }
  48.  
  49. ActionMailer::Base.delivery_method = :smtp
  50.  
  51. config.action_mailer.default_url_options = { :host => 'YOUR-DOMAIN-HERE.COM' }
  52.  
  53. Rails.application.routes.default_url_options[:host] = 'myappsname.herokuapp.com'
  54. config.action_mailer.delivery_method = :smtp
  55. config.action_mailer.perform_deliveries = true
  56. config.action_mailer.raise_delivery_errors = false
  57. config.action_mailer.default :charset => "utf-8"
  58.  
  59. class MyMailController < ApplicationController
  60. before_filter :set_host_from_request, only: [:create]
  61.  
  62. ....
  63.  
  64. private
  65. def set_host_from_request
  66. ActionMailer::Base.default_url_options = { host: request.host_with_port }
  67. end
  68. end
  69.  
  70. #config.action_mailer.default_url_options = { :host => 'mydomain.com' }
  71. $rails console
  72. User.invite!(email: "ceo@example.com")
  73. ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
  74. ...stacktrace
  75.  
  76. class ApplicationMailer < ActionMailer::Base
  77. default from: 'yourmail@gmail.com'
  78. layout 'mailer'
  79. end
  80.  
  81. config.action_mailer.default_url_options =
  82. { :host => 'yourapp.herokuapp.com' }
  83. config.action_mailer.delivery_method = :smtp
  84. config.action_mailer.smtp_settings = {
  85. address: 'smtp.gmail.com',
  86. port: 587,
  87. domain: 'heroku.com',
  88. user_name: 'yourmail@gmail.com',
  89. password: 'yourgmailpassword',
  90. authentication: 'login',
  91. enable_starttls_auto: true
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement