• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

PHP and SQL

I have the following code sending an email after someone joins. It works perfectly, but I would like the email sent as an HTML file so the <p></p> tags don't show up.
$config_sql = "SELECT * FROM Config WHERE Name='JoinSubmitEmailAddress'";
            $config_sql_result = mysql_query($config_sql);        
            if (mysql_num_rows($config_sql_result))
            {
                  $config_row = mysql_fetch_assoc($config_sql_result);
                  $mail_To = $SubmitEmail;               
                  $mail_From = "From: " . $config_row['Value'];
                  $mail_Subject = "Thank You For Joining";
                
                  $config_sql = "SELECT * FROM Content WHERE Page='JoinWelcomeEmail'";

                  $config_sql_result = mysql_query($config_sql);

                  if(!$config_sql_result) die(mysql_error());

                  $config_row = mysql_fetch_assoc($config_sql_result);

                  if(!$config_row) die('Configuration for JoinEmailSubmitted not found');                   

                  $message = 'Config: '.$config_row['PageContent'];

                 
		$body .= "First Name: " . stripslashes($FirstName); 

		$body .= "\nLast Name: " . stripslashes($LastName);
		
		$body .= "\nWedding Date: " . stripslashes($weddingdate);
		
		$body .= "\nPhone: " . stripslashes($phone_01);
		
		$body .= "\nUsername: " . stripslashes($SubmitEmail); 

		$body .= "\nPassword: " . stripslashes($Password);
		
		$body .= "\nWedding Date: " . stripslashes($weddingdate);

                 

                  $message = $config_row['PageContent']."\n\n";
$message .= "$body\n\n"; 


                  mail($mail_To, $mail_Subject, $message . "\n\n", $mail_From);

            }

            else

            {

                  echo "Error retrieving admin e-mail address from database\n";

                  exit;

            }

Open in new window

0
katlees
Asked:
katlees
1 Solution
 
Lukasz ChmielewskiCommented:
http://pl2.php.net/manual/en/function.mail.php
See example #4 - you have to add proper headers.
0
 
Dave BaldwinFixer of ProblemsCommented:
Take a look at http://php.net/manual/en/function.mail.php in the middle of the page.  In some circumstances, you might to generate a complete multipart mail format.  The PHPMailer() is more capable but more complicated.  http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html
0
 
scifo_dkCommented:
You need to add this:

$headers = "Content-type: text/html; charset=iso-8859-1\r\n";

$headers .= "\n ".$mail_From

And then use the $headers in the mail()-function, so it becomes:
mail($mail_To, $mail_Subject, $message . "\n\n", $mail_From);
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
katleesAuthor Commented:
Roads_Roads - I tried yours and no message was sent at all
scifo_dk - I tried yours and I still get the paragraph tags in the message
0
 
scifo_dkCommented:
Which e-mail client are you using?
0
 
Chris StanyonCommented:
@katlees:

Try creating your email message as a complete HTML page, including the <html> and <body> tags.

Change lines 39-40 to the following.

You'll also need to set the content type as scifo_dk has already suggested, and make sure your headers are set correctly.
$message = "<html><body>";
$message .= $config_row['PageContent'];
$message .= $body;
$message .= "</body></html>";

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now