Solved

display div background image in body of email

Posted on 2010-08-20
12
1,290 Views
Last Modified: 2012-05-10
I am having issues making a background image within a div show up in my the body of my reply email.

what am i doing wrong.

$to = "$email";	
$from = "sedm@atvrednecknationals.com";
$subject = "Can-am Survey";
$message = '<html>
<body style="background-color:#fff; color:#000; font-family:Georgia, Times, serif; line-height:1.8em;">
	<h3>
	  <a href="http://www.atvrednecknationals.com">
	  <img src="http://www.atvrednecknationals.com/images/logo.jpg" alt="ATV Redneck Nationals" width="216" height="61" border="0"></a>
    </h3>
	<h3>ATV Redneck Nationals</h3>
	  <hr color="#FDC613;" width="500px;">
	<p>Hello ' . $firstname . ',</p>
	<p>Thank you for applying for you can-am t-shirt or hat. Print this coupon and take it to your local can-am dealer for your choice of a 
	   t-shirt or hat from can-am. Thank you and do not forget to register for the <a href="http://www.atvrednecknationals.com">ATV Redneck Nationals</a> 
	   for your share of the $10,000 Championship.
	</p>
	  <hr color="#FDC613;" width="500px;">
	  <h3>Please check the following:</h3>
	  <div style="background-image:url(http://www.atvrednecknationals.com/images/coupon.jpg); width:500px; height:300px;">
	  <table>
	  	<tr>
			<td><b>Name:</b></td>
			<td style="color:#FF0000">' . $firstname .'</td>
		</tr>
		<tr>
			<td><b>Address:</b></td>
			<td style="color:#FF0000">' . $address .'</td>
		</tr>
		<tr>
			<td><b>City, State, Zip:</b></td>
			<td style="color:#FF0000">' . $city .'</td>
		</tr>
		<tr>
			<td><b>Phone:</b></td>
			<td style="color:#FF0000">' . $phone .'</td>
		</tr>
		<tr>
			<td><b>Email Address:</b></td>
			<td style="color:#FF0000">' . $email .'</td>
		</tr>
			
	  </table>
	  </div>
	  <hr color="#FDC613;" width="500px;">
	  <br />
	<p>~Southeastern Development & Marketing</p>
	
		
</body>
</html>';

Open in new window

0
Comment
Question by:chefkeifer
12 Comments
 
LVL 3

Expert Comment

by:Orion Newman
ID: 33488828
<div style="background-image:url('http://www.atvrednecknationals.com/images/coupon.jpg'); width:500px; height:300px;">

note the ' ' around the image location
0
 

Author Comment

by:chefkeifer
ID: 33488852
i changed it to this and still no results of the image in the body of the email
<div style="background-image:url("http://www.atvrednecknationals.com/images/coupon.jpg"); width:500px; height:300px;">

does it have to be singel quotes...
0
 
LVL 3

Accepted Solution

by:
Orion Newman earned 500 total points
ID: 33488867
example:

It's a single '  after the ( and then another single ' before the )

<div style="background-image:url('http://www.atvrednecknationals.com/images/coupon.jpg'); width:500px; height:300px;">

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:chefkeifer
ID: 33488887
using the single quotes will not let it process...here is the full code...

<?php
$username="root";
$password="****";
$database="atvRedneck";
//=============================================================//
$firstname=mysql_real_escape_string($_POST['firstname']);
$address  =mysql_real_escape_string($_POST['address']);
$city     =mysql_real_escape_string($_POST['city']);
$phone    =mysql_real_escape_string($_POST['phone']);
$email    =mysql_real_escape_string($_POST['email']);
//=============================================================//
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
//=============================================================//
$query = "INSERT INTO survey VALUES ('','$firstname','$address','$city','$phone','$email')";
mysql_query($query);
//=============================================================//
mysql_close();
//===============================================================
$to = "$email";	
$from = "sedm@atvrednecknationals.com";
$subject = "Can-am Survey";
$message = '<html>
<body style="background-color:#fff; color:#000; font-family:Georgia, Times, serif; line-height:1.8em;">
	<h3>
	  <a href="http://www.atvrednecknationals.com">
	  <img src="http://www.atvrednecknationals.com/images/logo.jpg" alt="ATV Redneck Nationals" width="216" height="61" border="0"></a>
    </h3>
	<h3>ATV Redneck Nationals</h3>
	  <hr color="#FDC613;" width="500px;">
	<p>Hello ' . $firstname . ',</p>
	<p>Thank you for applying for you can-am t-shirt or hat. Print this coupon and take it to your local can-am dealer for your choice of a 
	   t-shirt or hat from can-am. Thank you and do not forget to register for the <a href="http://www.atvrednecknationals.com">ATV Redneck Nationals</a> 
	   for your share of the $10,000 Championship.
	</p>
	  <hr color="#FDC613;" width="500px;">
	  <h3>Please check the following:</h3>
	  <div style="background-image:url(http://www.atvrednecknationals.com/images/coupon.jpg); width:500px; height:300px;">
	  <table>
	  	<tr>
			<td><b>Name:</b></td>
			<td style="color:#FF0000">' . $firstname .'</td>
		</tr>
		<tr>
			<td><b>Address:</b></td>
			<td style="color:#FF0000">' . $address .'</td>
		</tr>
		<tr>
			<td><b>City, State, Zip:</b></td>
			<td style="color:#FF0000">' . $city .'</td>
		</tr>
		<tr>
			<td><b>Phone:</b></td>
			<td style="color:#FF0000">' . $phone .'</td>
		</tr>
		<tr>
			<td><b>Email Address:</b></td>
			<td style="color:#FF0000">' . $email .'</td>
		</tr>
			
	  </table>
	  </div>
	  <hr color="#FDC613;" width="500px;">
	  <br />
	<p>~Southeastern Development & Marketing</p>
	
		
</body>
</html>';
//===============================================================
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $from\r\n";
$headers .= "CC: sedm@atvrednecknationals.com\r\n"; 
$headers .= "CC: aroberts@keifersdesign.com\r\n"; 
$headers .= "Bcc: kroberts@keifersdesign.com\r\n";
//===============================================================
$to = "$to";
    mail($to, $subject, $message, $headers);
	$my_msg = "Thanks $firstname, all data has been sent.";
    print "return_msg=". urlencode($my_msg); 
exit();
//===============================================================
?>

Open in new window

0
 
LVL 3

Expert Comment

by:Orion Newman
ID: 33488931
does it process without the div style?

Meaning without the style associated to the div?

<div>
          <table>
0
 

Author Comment

by:chefkeifer
ID: 33488960
it processes without the div all together..i have tried to do the background image in the table and that didnt work either...
0
 
LVL 3

Expert Comment

by:Orion Newman
ID: 33489047
Sometimes in php you have to put a \ in front of the apostraphe to make it display in html.

try that. I pasted the code below

<div style="background-image:url(\'http://www.atvrednecknationals.com/images/coupon.jpg\'); width:500px; height:300px;">

Open in new window

0
 

Author Comment

by:chefkeifer
ID: 33489098
putting the "\" let it process but still no image.. i know the path is right...
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33489279
How are you checking the email?  Are you allowing your email program to download images?
0
 
LVL 3

Expert Comment

by:Orion Newman
ID: 33489317
I uploaded your page to my server and was able to run it with the div tags and all as they were in your code snippet i removed the sql calls and typed in data for the variables.

is it something to do with the email client??

untitled.JPG
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 33491547
The kind of issues you're having with HTML email are very common, in part because there is no standard for rendering HTML in email messages.  Every email reader program has its own rendering engine.  Thus confusion reigns.  But fortunately there is a business that makes its living doing nothing but making it easy for you to send HTML email.  They provide easy-to-use templates for your messages, they provide the sign-up lists, they track who opened the messages, etc.  You can either fight the war yourself (an expensive, time-consuming and non-value-added activity) or you can hire Constant Contact.  Embarrassingly inexpensive.   Flawless service.  You can even get a free trial.

There are competitors, too.  But CC has worked well for me with several clients.
http://www.constantcontact.com/index.jsp

Bet of luck with your project, ~Ray
0
 

Author Comment

by:chefkeifer
ID: 33553716
sorry for the delay guys..had some other pressing issues to deal with. I will get back to this one shortly...thanks for everyones help..
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question