How to add logo image to mailer
Hi how can we add image from my assets to the email like my logo when sending email to the users.
You should just be able to use the regular old
<%= image_tag("logo.png") %> helpers just like you would use in your views. You may need to set your asset_host so that it includes a full URL for the images in the emails since they aren't displayed in the browser under your domain.
# I believe these should do the trick: config.action_controller.asset_host = 'http://localhost:3000' config.action_mailer.asset_host = config.action_controller.asset_host
@chris I use that approach but that get me another error.
Font from origin has been blocked from loading by Cross-Origin Resource Sharing policy
The email show the logo but now fonts are missing.
has I'm using subdomain
Oh fun, CORS is not a super fun thing to mess with. I'm not sure if you can do that with email, but you have to allow origins with CORS to determine where your fonts can be loaded from: http://stackoverflow.com/questions/27726802/css-font-being-blocked-from-cross-origin-resource-sharing-policy
O yes, I start reading about CORS but looks to shallow for me at the moment. As the problem with the fonts is on my site and not in the email. If I disable the image on email and hide the config for that all goes back to normal. So yes need to do a workaround the email images and the font cross site.
Ah cool. I've used https://github.com/cyu/rack-cors in the past to do that, but then I just started paying $50/yr for Typekit and no longer have to deal with that for almost any fonts I could want to use.
Why is it necessary to set both
config.action_controller.asset_host = 'http://localhost:3000' config.action_mailer.asset_host = config.action_controller.asset_host
Is it not possible to just set the
config.action_mailer.asset_host = 'http://localhost:3000' to have the full url in the mail?
If we set the
images_tag across the application, in normal views, will also use the the full usrl as
src instead os just the relative path.