0

I'm following an article on how to add styles to PHP email. It all works fine but as soon as I add my logo it stops working. But if I add their example, it works...

Their example of an image: <img src="//css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />

My image: <img src="//starlightradio.co.uk/images/email-logo.png" alt="Sea Match Rigs - Official Website" />

But for some reason it really doesn't want to work. The email just doesn't send with this image in there.

Here's my whole page of code:

<?php
$to = 'sam.carre2000@gmail.com';

$subject = 'Sea Match Rigs - Password Reset Link';

$headers = "From: noreply@seamatchrigs.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$message = '<html>
<div style="width:500px;margin:0 auto;margin-bottom:20px;margin-top:40px;"><img src="//starlightradio.co.uk/images/email-logo.png" alt="Sea Match Rigs - Official Website" /></div>
<head><link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"></head>
<body style="background-color:#2F8982;padding-top:50px;padding-bottom:50px;">
<div style="font-family:Open Sans, sans-serif;">
<div style="height:300px;width:500px;border:1px solid #ccc;border-radius:3px;padding:20px;margin:0 auto;background-color:#fff;">
<div style="color:#349891;font-weight:bold;font-size:25px;text-align:center;">Password Reset Details</div>
<div style="border-bottom:1px solid #349891;margin:0 auto;margin-top:15px;margin-bottom:15px;width:50%;"></div>
<div style="color:#000;font-size:20px;margin-top:10px;text-align:center;">It seems that you have requested to reset your password on <a href="http://seamatchrigs.co.uk" style="color:#000;text-decoration:none;"><b>seamatchrigs.co.uk</b></a>. <div style="color:#FFA500;margin-top:30px;">Please click the button below to reset your password on your account.</div>
<a href=""><div style="height:30px;width:200px;display:inline-block;border:1px solid #349891;color:#349891;padding:20px;border-radius:3px;margin-top:20px;">Click Here</div></a>
</div></body></html>';

mail($to, $subject, $message, $headers);

echo $message;
?>
Sammyjo20
  • 79
  • 2
  • 9
  • 1
    hissing `http:` also you have invalid HTML –  Aug 21 '16 at 21:14
  • Why don't you right click on the mail and `inspect element` where the image is supposed to be? Thats a great debugging technique. Check if the image shows up there. – Eisa Adil Aug 21 '16 at 21:16
  • Still doesn't work. Tried that already mate :/ – Sammyjo20 Aug 21 '16 at 21:16
  • I guess that gmail doesn't like your domain and blocks the image, thinking you're spamming. Try to use inline images: https://sendgrid.com/blog/embedding-images-emails-facts/ – KIKO Software Aug 21 '16 at 21:17
  • Problem is, is that with the image included, the email won't send. So can't really debug... – Sammyjo20 Aug 21 '16 at 21:18
  • The only way you would know the email doesn't get send is to look in the logs. What does it say there? – KIKO Software Aug 21 '16 at 21:20
  • I'm guessing you mean the server logs? Let me have a look :) – Sammyjo20 Aug 21 '16 at 21:21
  • Yes, the server logs. My guess is that the mail is send, but blocked by Google. Welcome to the nice world of mail... You could also try to send it to somewhere else than Google (or Microsoft). – KIKO Software Aug 21 '16 at 21:22
  • Right. I couldn't find any logs but I did find out that the email sent fine when I changed the email to send to my webserver. just didn't have a background color. http://image.prntscr.com/image/09eb0feed0ad4915aa106936d2f107fd.png – Sammyjo20 Aug 21 '16 at 21:25
  • Well, have a look at PHPmailer, it is much better for mailing than the build in mail() function. Also for embedded images. This doesn't help you since you're still not a good mail sender (reputation wise). You can send through a third party like www.sendgrid.com, that will help. – KIKO Software Aug 21 '16 at 21:28
  • Okay. Thanks for your help mate. I'll look into PHPmailer. Just need something that won't cost my employer anything more XD – Sammyjo20 Aug 21 '16 at 21:30
  • http://i1044.photobucket.com/albums/b448/Eisa_Adil/email-logo_zps14pbcxue.png Use that link once, it'll help – Eisa Adil Aug 21 '16 at 21:32

0 Answers0