Jump to content

Recommended Posts

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.

 

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

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...

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.