problem with mail script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

problem with mail script

Post by John Cartwright »

Okay I have my mail function which gathers the information and sends it

Code: Select all

<?php
mail ($to, $subject, "Name: $name\nE-mail: $email\nMessage: ".$_SESSION['message']." \n\nIP: $REMOTE_ADDR", "From: ".$_SESSION['email']."\n") or print "An unknown error occured.<br>";
?>
and this is where most of the information is put together:

Code: Select all

<?php
$feature =       array($logodesign,$bannerdesign,$graphicdesign,$shoppingcart, $interactivefeatures,$flashanimationandpresentation,
                       $webhosting,$domainnameregistration,$sitemaintenance, $editingandwritting,$merchantaccount,$customscripts,
					   $creditcardprocessing,$searchengineoptimization,$searchcapabilitiesonthewebsite,$databaseprogramming);

$message = 'Information about your project\n';
$message .= 'Type of site: '.$_SESSION['type'].'\n';		   
if ($type_other != ""){ 
$message .= 'Other: '.$_SESSION['type_other'].'\n'; 
} 
$message .= '<b>Features for the site: </b><br>';
foreach($feature as $feat){
if(isset($feat)){
$message .= '- '.$feat.'<br>';
}
} 
if (isset($features_other1)){
$message .= $features_other1.'<br>';
} 
$message .= '<b>Estimated Budget:</b> '.$_SESSION['budget'].'<br>';
$message .= '<b>Time until we can start project: </b>'.$_SESSION['time_start'].'<br>';
$message .= '<b>Time Frame: </b>'.$_SESSION['time_frame'].'<br>';
$message .= '<b>Overview: </b>'.$_SESSION['description'].'<br>'; 

echo "<br>";

echo "<table border="1" width="452" border="1" cellpadding="0" cellspacing="0" bordercolor="9A9A9A" align="center">\n".
     		"<tr class="porttext" bordercolor="EFEFEF" bgcolor="EFEFEF"><td width="5%"><td width="90%">\n";	 
echo "<br>".$message."<br>";
echo "<td width="5%">\n";
echo "</td></td></td></tr>\n";
echo "<tr bordercolor="EFEFEF" bgcolor="EFEFEF"><td><td><a class="conflink" href="?confirm=">Click here to confirm</a><br><td>&nbsp;</td>&nbsp;</td>&nbsp;</td></tr>\n";
echo "</table>\n";

$_SESSION['message'] = $message;
?>
The problem is all the html is being sent with it.... is there a way to strip the html out??
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

You need to have the email declared as HTML with this:

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I'm confused.. wut do u eman steveo?



*edit*

I want to keep the tags but I need them to get formatted the way they should be... any ideas?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Phenom wrote:I want to keep the tags but I need them to get formatted the way they should be... any ideas?
If i understand you correctly, then when you send the email it shows teh HTML tags, right? And you want the HTML to be activated right? If so then There isn't really much you can do about it. What Steveo suggested may work, but i know for a a fact that i can either choose to view my emails as either plain text or in HTML. So you don't have much control over that. But i may totaly be missing the point!
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

uhh.. you can also change < and > to their symbol codes.. (using str_replace or whatever)
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Phenom wrote:I'm confused.. wut do u eman steveo?
*edit*
I want to keep the tags but I need them to get formatted the way they should be... any ideas?
In the mail() function, there are 4 parameters. to, subject, message, and headers. Have the headers part be the code I gave you. Like this:

Code: Select all

<?php
//variable declaration here //
mail($to, $subject, $message, $headers);

?>
Post Reply