Solved

display div background image in body of email

Posted on 2010-08-20
12
1,287 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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 82

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 108

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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
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.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now