开发者

sending html mail with images not displaying in gmail

I am sending html emails through php . the email has a background image that is not showing when i test it with gmail, hotmail or yahoo mail. I have tried to use an image tag but that doesnt work either. the image works perfectly fine if using an email client like OSX Mail or Mozilla or outlook. Any ideas?

sorry about not adding any code. here is how i tried to implement it :

    <div style="border-bottom:1px solid #CCCCCC; padding:0 20px; background-color:#EDEDED; background-image:url(http://www.mysitename.com/images/email_header.png); background-repeat: no-repeat; background-position: 520px center; height:120px;"> 
Header 
</div>

gmail works fine for displaying other attachments and pictures but i guess it blocks html images ( even if 开发者_运维百科they r background images)


As you've found out, Gmail doesn't support CSS background images.

http://www.email-standards.org/ is a good resource for figuring out email rendering problems in different clients.


It turns out I was using CSS to have the picture in the background. Gmail didnt like that. instead i used an image tag. I cant substantiate this but : I have done that previously too with no success but what did previously is that i did not use tables for my layout. so to sum up... use tables for the layout of the html email insert image tag with width, height , alt tag and gmail , hotmail and yahoo would display ur image. hope this saves sometime for someone :)


You'll be able to make the background image work by using css. The trick is to not use shorthand and keep the css below the body tag. So rather than typing 'background: ...' make sure you type it fully and use: 'background-image:' 'background-color:' 'background-repeat:' etc. This show's perfectly in gmail etc for me.


In my case, I uploaded the image to https://imgur.com/
And replace old image link to new image link (from imgur), it works perfect.

<img width="60" src="https://i.imgur.com/PKqttNs.png" title="Logo" alt="Logo">


You haven't included any code or even an example of what your emails look like, so all I can do is give you a general suggestion:

Try sending an email from Gmail manually with an image back to your Gmail account. Confirm that the image displays. Now go to "Show original" and copy-and-paste that into a text file.

Now do the same with email sent from your program: send it to Gmail, "show original" and copy-and-pate into another file.

Now compare these two files. How are they different?


No Gmail does not support background-image property of CSS. I have tested it myself.

Check this out: http://www.email-standards.org/clients/gmail/


For my case, I need to replace SVG image by PNG version. No need any attribute for the image tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜