2

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.

Ahsan
  • 640
  • 6
  • 17
  • go to https://www.mailinator.com/ create a fake account, and try to send email to your fake account there. Just to check if the link wrapping is only in Gmail client or in all emails you send – equivalent8 Aug 18 '16 at 09:29

1 Answers1

2

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

Community
  • 1
  • 1
equivalent8
  • 13,754
  • 8
  • 81
  • 109
  • I am using gmail for sending email. Where should i find "wrap your links" in gmail account – Ahsan Aug 18 '16 at 08:25
  • don't know my friend, you will have to google that information. It's usually called "link tracking" ...but with gmail it may be that it's their security requirement, as you could post a malicious link, so this way if they discover that they just disable link on their side. – equivalent8 Aug 18 '16 at 08:27
  • I don't want to advertise or anything but I really recommend Sendgrid it's really straight forward, and options are clear https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html or Mailchimp/Mandril if you want to have remote templates – equivalent8 Aug 18 '16 at 08:29
  • why this, it should be Gost1 – Ahsan Aug 18 '16 at 08:30
  • I understand what is the problem, what I'm saying is that that's something that Gmail does in order to do link tracking or in order to improve security of links. I don't know how (or if it's possible) to turn it off if you set SMTP server to be Gmail, I was just recommending other alternative Cloud SMTP email provider that you can turn on/off this option. – equivalent8 Aug 18 '16 at 09:09
  • i am using Gmail for sending email as smtp server – Ahsan Aug 18 '16 at 12:34
  • ok this should help http://stackoverflow.com/questions/20903967/gmails-new-image-caching-is-breaking-image-links-in-newsletter it's a CDN cache – equivalent8 Aug 18 '16 at 15:34