- Phpmailer dropping name value on html emails, but working with plain text?
- Mail sent to: - crea@cruiseit.co.uk
- Mail sent to: Toms Tackle Tom Sawyer - crea@cruiseit.co.uk
- Mail sent to: - crea2k@o2.co.uk
- <?php
- $formid = mysql_real_escape_string($_GET[token]);
- $templatequery = mysql_query("SELECT * FROM hqfjt_chronoforms_data_addmailinglistmessage WHERE cf_id = '$formid'") or die(mysql_error());
- $templateData = mysql_fetch_object($templatequery);
- $gasoiluserTemplate = $templateData->gasoilusers;
- $dervuserTemplate = $templateData->dervusers;
- $kerouserTemplate = $templateData->kerousers;
- $templateMessage = $templateData->mailinglistgroupmessage;
- $templatename = $templateData->mailinglistgroupname;
- require_once('./send/class.phpmailer.php');
- $mailer= new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
- // Grab the FreakMailer class
- require_once('./send/MailClass.inc');
- // Grab our config settings
- require_once('./send/config.php');
- // Setup body
- $htmlBody = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <style>#title {padding-left:120px;padding-top:10px;font-family:"Times New Roman", Times, serif; font-size:22px; font-weight:bold; color:#fff;}</style>
- </head>
- <body>
- <div style="background:
- none repeat scroll 0% 0% rgb(6, 38,
- 97); width:780px;">
- <img id="_x0000_i1030" style="padding-left:100px;padding-right:100px;"
- src="http://www.chandlersoil.com/images/newsletter/header.gif"
- alt="Chandlers Oil and Gas"
- border="0" height="112"
- width="580">
- <div id="title">" . $templateMessage . "</div>
- </div>
- </body>
- </html>
- ';
- $textBody = "$templateData->mailinglistgroupmessage";
- // instantiate the class
- $mailer = new FreakMailer();
- // Get the user's Email
- $sql = mysql_query("SELECT leadname,businessname,email,mailtype FROM hqfjt_chronoforms_data_addupdatelead WHERE keromailinglist='$kerouserTemplate' AND dervmailinglist='$dervuserTemplate' AND gasoilmailinglist='$gasoiluserTemplate'");
- while($row = mysql_fetch_object($sql))
- {
- // Send the emails in this loop.
- $name = $row->leadname;
- $name = $row->businessname;
- $to_email = $row->email;
- $mailtype = $row->mailtype;
- if(!empty($row->businessname))
- {
- $name .= ' '.$row->leadname;
- }
- $to_name = $name;
- if($row->MailType == 'html')
- {
- $mailer->Body = str_replace('{name}', $name, $htmlBody);
- $mailer->IsHTML(true);
- $mailer->AltBody = str_replace('{name}', $name, $textBody);
- $mailer->AddAddress($to_email, $name);
- }
- else
- {
- $mailer->Body = str_replace('{name}', $name, $textBody);
- $mailer->isHTML(false);
- $mailer->AddAddress($to_email, $name);
- }
- $mailer->Send();
- $mailer->ClearAddresses();
- $mailer->ClearAttachments();
- $mailer->IsHTML(false);
- echo "Mail sent to: $name - $to_email<br />";
- }
- ?>
- $name = $row->leadname;
- $name = $row->businessname;
- class WhereIsThisAltered{
- protected $value;
- function __construct($value){
- $this->value = $value;
- }
- function __toString(){
- return $this->value;
- }
- function __destruct(){
- echo "Instance with value:{$this->value} desctructed";
- debug_print_backtrace();
- }
- }
- $name = new WhereIsThisAltered($row->leadname);
- <div id="title">" . $templateMessage . "</div>
- <div id="title">' . $templateMessage . '</div>