Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bad component(expected host component): received when running a rake task to send email with roadie on heroku

I'm using the roadie gem to help with the inline css for emails and am getting the following error when running a rake task to send emails. My app is hosted on heroku. It works fine in development mode, but get this error in production. I don't quite understand the issue. Other mailings are sent out fine in production. I'm pretty much a beginner. Thanks in advance for any help!

rake aborted!
bad component(expected host component): http://nameless-taiga-7547.herokuapp.com/
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:395:in `check_host'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:409:in `host='
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:180:in `initialize'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:126:in `new'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:126:in `build'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:206:in `absolute_url_base'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:192:in      `ensure_absolute_url'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:180:in `block in make_image_urls_absolute'
/app/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:239:in `block in each'
/app/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `upto'
/app/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:179:in `make_image_urls_absolute'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:57:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:80:in `block in adjust_html'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `tap'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `adjust_html'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:51:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie.rb:6:in `inline_css'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:75:in `inline_style_response'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:54:in `block in collect_responses_and_parts_order_with_inline_styles'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:54:in `map'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:54:in `collect_responses_and_parts_order_with_inline_styles'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:648:in `mail'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:35:in `mail_with_inline_styles'
/app/app/mailers/match_mailer.rb:13:in `deal_match'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/base.rb:167:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/base.rb:121:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/rendering.rb:45:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:458:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:452:in `initialize'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:439:in `new'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:439:in `method_missing'
/app/lib/tasks/match.rake:24:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/relation/delegation.rb:6:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/relation/delegation.rb:6:in `each'
/app/lib/tasks/match.rake:20:in `block (2 levels) in <top (required)>'
/app/lib/tasks/match.rake:9:in `each'
/app/lib/tasks/match.rake:9:in `block in <top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `<main>'

In my rake task

task :match => :environment do
...
end

Here is what is in my production.rb

config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
config.action_mailer.asset_host = { :host => 'http://nameless-taiga-7547.herokuapp.com/' }

ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => 'example',
:password => 'password',
:domain => 'heroku.com'
}

ActionMailer::Base.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => 'http://nameless-taiga-7547.herokuapp.com/' }
like image 931
jtmanuel Avatar asked Oct 01 '22 12:10

jtmanuel


1 Answers

You are asked to provide a Hostname, but you've instead provided a full URI. You should just provide the host:

config.action_mailer.asset_host = { :host => 'nameless-taiga-7547.herokuapp.com' }
config.action_mailer.default_url_options = { :host => 'nameless-taiga-7547.herokuapp.com' }
like image 153
Winfield Avatar answered Oct 13 '22 12:10

Winfield