vozzek Posted October 2, 2007 Share Posted October 2, 2007 Hi all, Quick question: I've got a php script calling some java code that executes a "send to friend" email from the url of my website to a chosen email address. Works great. Last thing I need is to maybe embed a small company logo within the body of the email, so when they open it up they can see it. I've tried different things with the code below (do I maybe have to echo it?), but can't get more than a link to show up: <?PHP global $_POST; $uname = $_POST["yourname"] ; $uemail = $_POST["youremail"]; $fname = $_POST["friendsname"]; $femail = $_POST["friendsemail"]; $message = $_POST["message"]; $link = $_POST["link"]; $to = "$femail"; $subject = "$uname Wants You To Check Out This Website"; $headers = "From: $uemail\n"; $logo = "<img src='http://www.mywebsite.com/images/small_logo.jpg'></img>"; $message = "Hello $fname. $uname wants you to visit $link\n $logo\n $message"; if (preg_match(' /[\r\n,;\'"]/ ', $_POST['uemail'])) { exit('Invalid Email Address'); } else { mail($to,$subject,$message,$headers); } ?> The red code is the stuff I added to try and get the image to show up. Any ideas? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/71517-embedding-an-email-image-within-php-script/ Share on other sites More sharing options...
MmmVomit Posted October 2, 2007 Share Posted October 2, 2007 Try getting rid of the </img> tag. I don't know if that's what is causing the problem, but img tags don't need to be closed. Quote Link to comment https://forums.phpfreaks.com/topic/71517-embedding-an-email-image-within-php-script/#findComment-360057 Share on other sites More sharing options...
shocker-z Posted October 2, 2007 Share Posted October 2, 2007 It could be that the email host your sending to has a security measure that stops external images being shown on emails.. Easy way to test your code is to echo instead of mailing and see if the image show's up. just try this code on a seperate page: $logo = "<img src='http://www.mywebsite.com/images/small_logo.jpg'></img>"; echo "Hello $fname. $uname wants you to visit $link\n $logo\n $message"; if it doesn't show then error in HTML if it does then it's security of the email provider. Regards Liam Quote Link to comment https://forums.phpfreaks.com/topic/71517-embedding-an-email-image-within-php-script/#findComment-360068 Share on other sites More sharing options...
vozzek Posted October 2, 2007 Author Share Posted October 2, 2007 Thanks Liam. I tried what you said and was able to see the image in a different file, so I figured Gmail must be blocking the image using the traditional <img> html tag. However... my cousin sends me emails (through Gmail) all the time, and the logo of his mortgage company is always embedded at the bottom of the mail. So there must be a way to do it. When I click on the element properties of the image in one of his emails it says: http://mail.google.com/mail/?attid=0.1&disp=emb&view=att&th=1155d0ab78e4c1b4 The disp=emb and view=att must have something to do with allowing me to see his image, but truth be told it's all greek to me... Quote Link to comment https://forums.phpfreaks.com/topic/71517-embedding-an-email-image-within-php-script/#findComment-360084 Share on other sites More sharing options...
shocker-z Posted October 2, 2007 Share Posted October 2, 2007 You must have received the email once before and clicked always show else his image iss attached to the email and embedded inside it. Gmail block ALL external images or a less you have acepted. Liam Quote Link to comment https://forums.phpfreaks.com/topic/71517-embedding-an-email-image-within-php-script/#findComment-360100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.