HTML email image tag missing src attribute

2019-08-06 20:32发布

问题:

I have a problem that I cant find the answer by Googling. I hope I can get one here. My problem is: My system can send email to user. On local, an image tag on email is like this:

<img src="http://myimageurl" width="300" style="display:block;margin:auto" alt="">

When working on real server:

<img width="300" style="display:block;margin:auto" alt="">

As you can see, my src attribute is disspeared. I just dont know why!

My email tempalte(Im using cakePhp):

<?php 
echo $this->Html->image(
    Router::url('/', true). 'img/eventflair-logo.png',
        array(
            'width' => '300',
            'style' => 'display:block; margin: auto'
        )); 
?>

Best Regards.

回答1:

Gmail by default doesn't show images in email. To see the original email source select "show original" from email dropdown menu.



回答2:

It seems gmail recently become more strict on urls allowed in emails. I had an img url that was formatted like "//cdn.someurl.com" which would render find on gmail until around a month ago, and is now having problems like you described.

It looks like gmail is auto appending the http:// to the url, so taking out the 2 leading /s worked for me. Maybe taking out the http:// from your url will work.