Rails Action Mailer: images in emails

Pavel Babin picture Pavel Babin · Mar 4, 2014 · Viewed 20.5k times · Source

I'm trying to paste images into email. The problem is emails comming without images inside

development.rb

  config.action_mailer.default_url_options = {
    :host => 'localhost:3000',
    :only_path => false
  }
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.asset_host = 'http://localhost:3000'

view file:

<div class="image">
  <%= image_tag image_path('email-logo.png') %>
</div>

Where did I make a mistake? Please ask if you need more information.

Answer

a14m picture a14m · Mar 6, 2014

try

<div class="image">
  <%= image_tag('email-logo.png') %>
</div>

Make sure you set config.action_controller.asset_host and config.action_mailer.asset_host