I have a php script that i use to send mails to lists of emails in my database, but the mail appears in text form only. Now i want my subscribers to get their mails in HTML format.
Please help me out.

5 Years
Discussion Span
Last Post by cereal

Thanks, I tried it but i still get the mail in full-text format but i want my mails to appear in HTML format. Can u help out, this is the code i used.

require_once "Mail.php";
error_reporting(E_ALL - (E_NOTICE + E_WARNING));

 $form_string= <<<EOFORM
     <TITLE>Send a Newsletter</TITLE>
   	<h2>Send  Newsletter</h2>
    <form method="POST" action="$_SERVER[PHP_SELF]">
    <input type="text" name="subject" size=30></p>
    <P><strong>Mail Body:</strong><br>
    <textarea name="message" cols=50 rows=10 wrap=virtual></textarea>
    <input type="hidden" name="op" value="send">
    <p><input type="submit" name="submit" value="Send Now"></p>
$from = "info@seapmicrofinance.org";
$subject = stripslashes($_POST['subject']);
$message = '
  <title>Birthday Reminders for August</title>
  <p>Here are the birthdays upcoming in August!</p>
  <table bgcolor=#EEEEEE>

$username = "USERNAME";
$password = "PASSWORD";
$host = "smtp.seapmicrofinance.org";  // replace this with your domain's webmail address, for example "smtp.YourDomain.com"

  if ($_POST[op] != "send") {
     //haven't seen the form, so show it
	echo $form_string;

 } else if ($_POST[op] == "send") {
     //want to send form, so check for required fields
     if (($_POST[subject] =="") || ($_POST[message] == "")) {
        header("Location: mailing_script2.php");

    //connect to database
    $conn = mysql_connect("XpertProCombined", "gbenga", "micrBANK1@")
         or die(mysql_error());
    mysql_select_db("seap?users",$conn) or die('Connection Failed!');

    //get emails from subscribers list
    $sql = "select user_email from users";
    $result = mysql_query($sql,$conn) or die(mysql_error());

    //create a From: mailheader
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: SEAP Microfinance <info@seapmicrofinance.org>";

    //loop through results and send mail
    while ($row = mysql_fetch_array($result)) {
        $email = $row['user_email'];
		$headers = array ('From' => $from, 'To' => $email, 'Subject' => $subject);
	    $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
		$mail = $smtp->send($email, $headers, $message);
		 echo "newsletter sent to: $email<br>";
	if (PEAR::isError($mail)) 
  			echo("<p>" . $mail->getMessage() . "</p>");


Edited by peter_budo: Added code tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.