Link to home
Start Free TrialLog in
Avatar of katlees
katleesFlag for United States of America

asked on

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

Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

http://pl2.php.net/manual/en/function.mail.php
See example #4 - you have to add proper headers.
Avatar of Dave Baldwin
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
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);
Avatar of katlees

ASKER

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
Which e-mail client are you using?
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial