Ahsan
Ahsan

Reputation: 650

Rails 4 action mailer image absolute path added with proxy https path in sending mail

I am trying to send mail with with image. I checked with letter_opener gem and it's OK but when i receive mail in my gmail account, the image is missing. image src showing the path https://ci6.googleusercontent.com/proxy/RLRFotvE91M7TbTVT8Todcjnjv9ymRfVHwxGRJpV-OcuAhGKbUeokSngMmgp74L6wYKN0jiiGZjbRP7StvXK3KWL7ttUSg=s0-d-e1-ft#http://localhost:3000/uploads/image/17/gost1.jpg but it should be only http://localhost:3000/uploads/image/17/gost1.jpg and it will be okay. The image tag like:

<%= image_tag(@image_for_artist) %><br>
development.erb=> 
 config.action_controller.asset_host = 'localhost:3000'
 config.action_mailer.asset_host = 'http://localhost:3000'

Why image tag not showing absolute path instead of ci6.googleusercontent.com path.

Upvotes: 2

Views: 821

Answers (1)

equivalent8
equivalent8

Reputation: 14237

I can give you a Sendgrid example as to why is this happening. Basically you can configure whether email provider should "wrap your links" . So for example, Sendgrid is doing this in order to do the tracking and other aggregation of data around links (like if the sign up link was clicked, and how many times) which is super useful, but not pretty.

So my guess will be that you can disable this somewhere in your account of the email cloud provider.

update

ok we need to clarify something. Gmail can be used both as a email client for receiving emails but also as SMTP server for sending emails. My understanding was that you are saying you are using Gmail as SMTP server. Can you pls clarify how you are sending emails ? Is your app using sendmail, postfix, ... other built in email server solution, or are you using 3rd party SMTP server (cloud) for sending emails like Gmail SMTP, Sendgrid, Mandrill... ?

Update2

The application was using Gmail SMTP server. In this SO question is a solution -> Gmail's new image caching is breaking image links in newsletter

Upvotes: 2

Related Questions