Skip to content

Commit

Permalink
FireGento_Logger_Model_Mail: Character-Encoding of Mail Body
Browse files Browse the repository at this point in the history
The default content-type of outgoing logging emails is:

    Content-Type: text/plain; charset=iso-8859-1

As not all sites use iso-8859-1 as charset, an option has been added
to the mail-logger to allow setting your own charset parameter value.

- Added charset setting to mailconfig
- Instantiate Zend_Mail with charset

Ref: firegento#35
  • Loading branch information
tkdb committed Jul 21, 2014
1 parent 6ec1c95 commit 7b3d7e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/code/community/FireGento/Logger/Model/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ public function _write($event)
public function getMail()
{
if ($this->_mail === null) {
$this->_mail = new Zend_Mail();

/** @var $helper FireGento_Logger_Helper_Data */
$helper = Mage::helper('firegento_logger');

$charset = $helper->getLoggerConfig('mailconfig/charset');
$charset = filter_var($charset, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
if ($charset !== false) {
$charset = strtolower(trim($charset));
}
$charset = strlen($charset) ? $charset : null;

$this->_mail = new Zend_Mail($charset);

$storeName = Mage::app()->getStore()->getName();
$subject = $storeName .' - Debug Information';

Expand Down
7 changes: 7 additions & 0 deletions src/app/code/community/FireGento/Logger/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
</to>
<charset translate="label">
<label>Charset</label>
<frontend_type>text</frontend_type>
<sort_order>60</sort_order>
<show_in_default>1</show_in_default>
<comment>Defaults to "iso-8859-1", suggested: "utf-8".</comment>
</charset>
</fields>
</mailconfig>
<db translate="label">
Expand Down

0 comments on commit 7b3d7e0

Please sign in to comment.