Jump to content

how to insert style in php


salman_ahad@yahoo.com

Recommended Posts

 

I am trying to send email using mail() function.

 

I want to be able to include the css style in message too. My present code is

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
.style1 {
color: #777777;
}
.style2 {
color: #666666;
}
</style>
</head>
</html>


<?php
$to = "xyz@mysite.com";
$subject = "promotion";
$message = ''
.	'<table width="520" border="0" bordercolor="#FFFFFF">'
.	'  <tr>'
.	'    <td width="514" height="90"><p> </p>'
.	'    <p><span class="style1">Reach out to Community!! </span></p>'
.	'        <span class="style2">1. Click the mail below.</span><br /><br /> </td>'
.	'  </tr>'
.	'</table>';
mail($to, $subject, $message);
?>

 

 

Link to comment
Share on other sites

You can put the style within your $message. Something that I've come to do is include a php script.

 

MAIL SCRIPT

<?php
$to = "xyz@mysite.com";
$subject = "promotion";
include('emailToSend.html');
mail($to, $subject, $message);
?>

 

$body in mail

<?php
$body = "
<html>
<head>
<style type='text/css'>
.style1 {
color: #777777;
}
.style2 {
color: #666666;
}
</style>
</head>
<body>
.	'<table width="520" border="0" bordercolor="#FFFFFF">'
.	'  <tr>'
.	'    <td width="514" height="90"><p> </p>'
.	'    <p><span class="style1">Reach out to Community!! </span></p>'
.	'        <span class="style2">1. Click the mail below.</span><br /><br /> </td>'
.	'  </tr>'
.	'</table>';
</body>
</html>";
?>

 

edit: I copied your stuff into the second script... so it wont work because of the quotes but you get the idea...

Link to comment
Share on other sites

 

so I am sending the mail in html form, what am I missing...whats wrong?

 

<?php 
require('includes/connection.php');
$to_email = 'mohammed.ahad@gmail.com';
$subject = 'How to forward Islamic emails';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.style1 {color: #990000}
.style2 {
color: #000033;
font-weight: bold;
}
.style3 {
color: #003300;
font-weight: bold;
}
.style4 {
color: #993300;
font-weight: bold;
}
.style5 {color: #000000}
.style6 {color: #000000; font-weight: bold; }
.style7 {color: #333333}
</style>
</head>

<body>
<?php
$message = ''
.'<table width="520" border="0">'
.	'<tr>'
.		'<td width="514"><img src="http://www.ideatoceo.com/emails/kalima.gif" width="514" height="89" longdesc="http://shetech.ideatoceo.com" /></td>'
.	'</tr>'
.	'<tr>'
.		'<td>'
	.'<table width="512" border="0">'
	.	'<tr>'
	.		'<td width="251" al>  <div align="center"><span class="style7">Group of professionals are now ready to train muslims FREE</span></div>'
	.		'<p>   <span class="style2">PHP</span>		<br />   <span class="style3">MySQL</span><br />   <span class="style4">Web Services <span class="style5">& more</span></span><span class="style6">...</span></p>'
	.		'<p align="center" class="style1">Work on live projects and get trained!'
	.		'</td>'
	.		'<td width="251"><img src="http://www.ideatoceo.com/emails/training.gif" width="205" height="204" align="right" longdesc="http://shetech.ideatoceo.com" /></td>'
    .	'</tr>'
	.'</table>'
.		'</td>'
.	'</tr>'
.	'<tr>'
.		'<td><label><label><img src="http://www.ideatoceo.com/emails/Bottom2.gif" width="514" height="48" longdesc="http://shetech.ideatoceo.com" /></label></label></td>'
.	'</tr>'
.'</table>'
.'<table>'
  	.'Forwarding Hadith to friends is now easy, visit <a href="http://www.ideatoceo.com/islam-emails.php" target="_blank">IdeatoCEO </a><br />'
.'<a href="http://www.ideatoceo.com/islam/emails.php" target="_blank">Unsubscribe</a> from the distribution<br />'
.	'<br />'
.'www.ideatoceo.com | 192 allen ave | Saint Louis | MO | 63104 <br  />'
.'</table>';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= "X-Priority: 1 (Higuest)\n"; 
$headers .= "X-MSMail-Priority: High\n"; 
$headers .= "Importance: High\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: islam@ideatoceo.com' . "\r\n";	
mail($to_email, $subject, $message, $headers);	
?>
</body>
</html>

Link to comment
Share on other sites

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.