Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 5.25 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Phpmailer dropping name value on html emails, but working with plain text?
  2. Mail sent to: - crea@cruiseit.co.uk
  3.  Mail sent to: Toms Tackle Tom Sawyer - crea@cruiseit.co.uk
  4. Mail sent to: - crea2k@o2.co.uk
  5.        
  6. <?php
  7.                   $formid = mysql_real_escape_string($_GET[token]);
  8.                               $templatequery = mysql_query("SELECT * FROM hqfjt_chronoforms_data_addmailinglistmessage WHERE cf_id = '$formid'") or die(mysql_error());
  9.                               $templateData = mysql_fetch_object($templatequery);
  10.  
  11.                               $gasoiluserTemplate = $templateData->gasoilusers;
  12.                               $dervuserTemplate = $templateData->dervusers;
  13.                               $kerouserTemplate = $templateData->kerousers;
  14.                               $templateMessage = $templateData->mailinglistgroupmessage;
  15.                               $templatename = $templateData->mailinglistgroupname;
  16.  
  17.  
  18.                 require_once('./send/class.phpmailer.php');
  19.  
  20.                $mailer= new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
  21.  
  22.                // Grab the FreakMailer class
  23.                 require_once('./send/MailClass.inc');
  24.  
  25.                 // Grab our config settings
  26.                 require_once('./send/config.php');
  27.  
  28.               // Setup body
  29.               $htmlBody = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  30.                               <html xmlns="http://www.w3.org/1999/xhtml">
  31.                               <head>
  32.                               <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  33.                               <style>#title {padding-left:120px;padding-top:10px;font-family:"Times New Roman", Times, serif; font-size:22px; font-weight:bold; color:#fff;}</style>
  34.                               </head>
  35.  
  36.                               <body>
  37.                               <div style="background:
  38.                                                                 none repeat scroll 0% 0% rgb(6, 38,
  39.                                                                 97); width:780px;">
  40.                               <img id="_x0000_i1030" style="padding-left:100px;padding-right:100px;"
  41.                                                                     src="http://www.chandlersoil.com/images/newsletter/header.gif"
  42.                                                                     alt="Chandlers Oil and Gas"
  43.                                                                     border="0" height="112"
  44.                                                                     width="580">
  45.                                                                     <div id="title">" . $templateMessage . "</div>
  46.  
  47.                                                                     </div>
  48.                               </body>
  49.                               </html>
  50.                               ';
  51.                $textBody = "$templateData->mailinglistgroupmessage";
  52.  
  53.               // instantiate the class
  54.               $mailer = new FreakMailer();
  55.  
  56.               // Get the user's Email
  57.               $sql = mysql_query("SELECT leadname,businessname,email,mailtype FROM hqfjt_chronoforms_data_addupdatelead WHERE keromailinglist='$kerouserTemplate' AND dervmailinglist='$dervuserTemplate' AND gasoilmailinglist='$gasoiluserTemplate'");
  58.  
  59.               while($row = mysql_fetch_object($sql))
  60.               {
  61.                   // Send the emails in this loop.
  62.                   $name = $row->leadname;
  63.                    $name = $row->businessname;
  64.                     $to_email = $row->email;
  65.                     $mailtype = $row->mailtype;
  66.                   if(!empty($row->businessname))
  67.                   {
  68.                       $name .= ' '.$row->leadname;
  69.                   }
  70.                   $to_name = $name;
  71.                   if($row->MailType == 'html')
  72.                   {
  73.                       $mailer->Body = str_replace('{name}', $name, $htmlBody);
  74.                       $mailer->IsHTML(true);
  75.                       $mailer->AltBody = str_replace('{name}', $name, $textBody);
  76.                       $mailer->AddAddress($to_email, $name);
  77.                   }
  78.                   else
  79.                   {
  80.                       $mailer->Body = str_replace('{name}', $name, $textBody);
  81.                       $mailer->isHTML(false);
  82.                           $mailer->AddAddress($to_email, $name);
  83.                   }
  84.                   $mailer->Send();
  85.                   $mailer->ClearAddresses();
  86.                   $mailer->ClearAttachments();
  87.                   $mailer->IsHTML(false);
  88.                   echo "Mail sent to: $name - $to_email<br />";
  89.               }
  90.  
  91.               ?>
  92.        
  93. $name = $row->leadname;
  94. $name = $row->businessname;
  95.        
  96. class WhereIsThisAltered{
  97.      protected $value;
  98.      function __construct($value){
  99.           $this->value = $value;
  100.      }
  101.      function __toString(){
  102.          return $this->value;
  103.      }
  104.      function __destruct(){
  105.          echo "Instance with value:{$this->value} desctructed";
  106.          debug_print_backtrace();
  107.      }
  108. }
  109.  
  110. $name = new WhereIsThisAltered($row->leadname);
  111.        
  112. <div id="title">" . $templateMessage . "</div>
  113.        
  114. <div id="title">' . $templateMessage . '</div>