Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add idna-compatible mail-address encodings #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/code/local/Aschroder/SMTPPro/Model/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @copyright Copyright (c) 2014 Ashley Schroder
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
require Mage::getBaseDir().'vendor/autoload.php';

class Aschroder_SMTPPro_Model_Email extends Mage_Core_Model_Email {

Expand All @@ -32,9 +33,10 @@ public function send() {
} else {
$mail->setBodyText($this->getBody());
}
$idn = new \Mso\IdnaConvert\IdnaConvert();

$mail->setFrom($this->getFromEmail(), $this->getFromName())
->addTo($this->getToEmail(), $this->getToName())
->addTo($idn->encode($this->getToEmail()), $idn->encode($this->getToName()))
->setSubject($this->getSubject());

$transport = new Varien_Object(); // for observers to set if required
Expand Down
5 changes: 4 additions & 1 deletion app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

require Mage::getBaseDir().'/vendor/autoload.php';
/**
* This class wraps the Queue to add email sending functionality
* If enabled it will send emails using the given configuration.
Expand Down Expand Up @@ -58,6 +58,9 @@ public function send()
$mailer = new Zend_Mail('utf-8');
foreach ($message->getRecipients() as $recipient) {
list($email, $name, $type) = $recipient;
$idn = new Mso\IdnaConvert\IdnaConvert();
$email = $idn->encode($email);

switch ($type) {
case self::EMAIL_TYPE_BCC:
$mailer->addBcc($email, '=?utf-8?B?' . base64_encode($name) . '?=');
Expand Down