Hey everyone,
I am stumped once more and you guys have always helped in one way or the other.
I am just now starting to fool around with using PEAR to send html emails. Following the sample scripts -- http://www.phpmaniac.net/wiki/index....ple_recipients -- I was able to send html emails with no problem.
However, when I applied these concepts to a dynamically generated email, the recipients would receive an email with random equal signs appearing in the email.
Here's the code:
Here's the result:
I am stumped once more and you guys have always helped in one way or the other.
I am just now starting to fool around with using PEAR to send html emails. Following the sample scripts -- http://www.phpmaniac.net/wiki/index....ple_recipients -- I was able to send html emails with no problem.
However, when I applied these concepts to a dynamically generated email, the recipients would receive an email with random equal signs appearing in the email.
Here's the code:
Code:
$message = '<table>';
// used for displaying thank you page after the form is submitted
$email_message = $new_html_var2;
if(!empty($_POST['typeSub']))
{
$message =$message. '<tr><td>Thank you for ordering '.$_POST['typeSub'].' subscription of Script Magazine</td></tr>';
}
if(!empty($_POST['bfname']))
{
$message=$message. '<tr><td>Billing Info'.'</td></tr><tr><td>'.'First Name: '.$_POST['bfname'].'</td></tr>';
}
if(!empty($_POST['blname']))
{
$message=$message. '<tr><td>Last Name: '.$_POST['blname'].'</td></tr>';
}
if(!empty($_POST['bcompany']))
{
$message=$message. '<tr><td>Company: '.$_POST['bcompany'].'</td></tr>';
}
if(!empty($_POST['baddress1']))
{
$message=$message. '<tr><td>Address 1: '.$_POST['baddress1'].'</td></tr>';
}
if(!empty($_POST['baddress2']))
{
$message=$message. '<tr><td>Address 2: '.$_POST['baddress2'].'</td></tr>';
}
if(!empty($_POST['bcity']))
{
$message=$message. '<tr><td>City: '.$_POST['bcity'].'</td></tr>';
}
if(!empty($_POST['bstate']))
{
$message=$message. '<tr><td>State: '.$_POST['bstate'].'</td></tr>';
}
if(!empty($_POST['bzip']))
{
$message=$message. '<tr><td>Zip/Postal Code: '.$_POST['bzip'].'</td></tr>';
}
if(!empty($_POST['bcountry']))
{
$message=$message. '<tr><td>Country: '.$_POST['bcountry'].'</td></tr>';
}
if(!empty($_POST['bemail']))
{
$message=$message. '<tr><td>Email: '.$_POST['bemail'].'</td></tr>';
}
if(!empty($_POST['bphone']))
{
$message=$message. '<tr><td>Phone: '.$_POST['bphone'].'</td></tr>';
}
if(!empty($_POST['ACCT']))
{
$message=$message. '<tr><td>Card number ending in: '.substr($_POST['ACCT'], -4).'</td></tr>';
}
if(!empty($_POST['sfname']))
{
$message=$message. '<tr><td>Shipping Info'.'</td></tr><tr><td>'.'First Name: '.$_POST['scompany'].'</td></tr>';
}
if(!empty($_POST['slname']))
{
$message=$message. '<tr><td>Last Name: '.$_POST['slname'].'</td></tr>';
}
if(!empty($_POST['scompany']))
{
$message=$message. '<tr><td>Company: '.$_POST['scompany'].'</td></tr>';
}
if(!empty($_POST['saddress1']))
{
$message=$message. '<tr><td>Address 1: '.$_POST['saddress1'].'</td></tr>';
}
if(!empty($_POST['saddress2']))
{
$message=$message. '<tr><td>Address 2: '.$_POST['saddress2'].'</td></tr>';
}
if(!empty($_POST['scity']))
{
$message=$message. '<tr><td>City: '.$_POST['scity'].'</td></tr>';
}
if(!empty($_POST['sstate']))
{
$message=$message. '<tr><td>State: '.$_POST['sstate'].'</td></tr>';
}
if(!empty($_POST['szip']))
{
$message=$message. '<tr><td>Zip/Postal Code: '.$_POST['szip'].'</td></tr>';
}
if(!empty($_POST['scountry']))
{
$message=$message. '<tr><td>Country: '.$_POST['scountry'].'</td></tr>';
}
$message=$message. '</table>';
$email_message .= $message.'</div></body></html>';
$message2 = '<html><body>'.$message;
$message2 .= '</body></html>';
$my_subject = 'Some Magazine Order';
$recipients = "'<someone1@example.com>, <someone2@example.com>, ";
$recipient = $_POST['bemail'];
$from_mail = "noreply@example.com";
// To send HTML mail, the Content-type header must be set
include('Mail.php');
include('Mail/mime.php');
$all_recipients = $recipients."<".$recipient.">'";
$html = $message2;
//$crlf = "rn";
$hdrs = array('From' => $from_mail,
'To' => $all_recipients,
'Subject' => $my_subject,
'Headers' => $hdrs
);
$mime = new Mail_mime();
// $mime->setTXTBody($text);
$mime->setHTMLBody($html);
// $mime->addAttachment($file,'application/octet-stream');
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail', $params);
$mail->send($all_recipients, $hdrs, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo($email_message);
}
Code:
<tbody><tr><td>Thank you for ordering 1 year US subscription o= f some Magazine</td></tr><tr><td>Billing Info</td></tr><tr><td>First Name= : kronus</td></tr><tr><td>Last Name: agia</td></tr><tr><td>Company: fd</td>= </tr><tr><td>Address 1: olympus</td></tr><tr><td>City: metro</td></tr><tr><= td>State: California</tr><tr><td>Zip/Postal Code: 90004</td></tr><tr><= td>Country: United States</tr><tr><td>Email: someemail@hotmail.com</td></tr><tr><td>Phone: 8185555555</td></tr><tr><td>Card number ending in: 510= 0</td></tr><tr><td>Country: United States</td></tr></tbody>