Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

display div background image in body of email

Posted on 2010-08-20
12
Medium Priority
?
1,308 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 84

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 111

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

886 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