Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

display div background image in body of email

Posted on 2010-08-20
12
Medium Priority
?
1,303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

661 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