View Single Post
  #9  
Old 04-03-2015, 04:52 AM
 
JannieB JannieB is offline
 

Senior Member
  
Join Date: Sep 2004
Posts: 117
 

Default Re: Customize Email & Invoce

Hi Tony,

Thank you - I think I have fixed the problem now .....

When looking at the html output I noticed the lines were broken up, sometimes in the middle of an html tag which seemed to cause formatting problems. Also some rogue characters were introduced.

Rogue unprintable characters can be intoduced by UTF-8 files which have the UTF-8 BOM at the beginning. I don't know if they had, but I went through each template in Dreamweaver and re-saved them with UTF-8 and no BOM.

The line breaks were a result of the encoding (I think), looking in Xlite/View/Mailer.php the encoding was set to "quoted-printable" in the initMailFromConfig() function. The default used by PHP Mailer is 8-bit, so I just commented out this line

Code:
$this->mail->Encoding = 'quoted-printable';

in the var/run version of the Mailer.php file, so that it would use the default setting and to see if it made any difference. The email then came through correctly formatted.

So I have know add a decorated version of Mailer.php to my module as follows:

Code:
class Mailer extends \XLite\View\Mailer implements \XLite\Base\IDecorator { /** * Inner mailer initialization from DB configuration * * @return void */ protected function initMailFromConfig() { if (!isset($this->mail)) { // Initialize PHPMailer include_once LC_DIR_LIB . 'PHPMailer' . LC_DS . 'class.phpmailer.php'; $this->mail = new \PHPMailer(); // SMTP settings if (\XLite\Core\Config::getInstance()->Email->use_smtp) { $this->mail->Mailer = 'smtp'; $this->mail->Host = \XLite\Core\Config::getInstance()->Email->smtp_server_url; $this->mail->Port = \XLite\Core\Config::getInstance()->Email->smtp_server_port; if (\XLite\Core\Config::getInstance()->Email->use_smtp_auth) { $this->mail->SMTPAuth = true; $this->mail->Username = \XLite\Core\Config::getInstance()->Email->smtp_username; $this->mail->Password = \XLite\Core\Config::getInstance()->Email->smtp_password; } if (in_array(\XLite\Core\Config::getInstance()->Email->smtp_security, array('ssl', 'tls'))) { $this->mail->SMTPSecure = \XLite\Core\Config::getInstance()->Email->smtp_security; } } $this->mail->SMTPDebug = true; $this->mail->IsHTML(true); } } }

The weird thing is, that I am sure this wasn't happening before ... anyway it seems to be OK now, so now I just need to restyle all the emails to meet the designers brief ... oh joy!

Thanks,

Jan
__________________
Jan Beesley
(Currently Xcart 5
Previously XCart Gold from 3.5....)
Reply With Quote