Commit dee1889c authored by Kseniya's avatar Kseniya
Browse files

indn fix

parent a0014166
{
"name": "drupal/synhelper",
"description": "Helper func",
"type": "drupal-module",
"license": "GPL-2.0+",
"require": {
"algo26-matthias/idna-convert": "^3.0"
}
}
......@@ -2,7 +2,7 @@
namespace Drupal\synhelper\Hook;
use Drupal\synhelper\Controller\IdnaConvert;
use Algo26\IdnaConvert\ToIdn;
/**
* PreprocessHtml.
......@@ -13,17 +13,18 @@ class PhpmailAlterFromAlter {
* Hook.
*/
public static function hook(&$mail) {
$idn = new IdnaConvert();
$idna = new ToIdn();
// $unicode = new Algo26\IdnaConvert\ToUnicode();
$mail = trim($mail);
$user = strstr($mail, '@', TRUE);
$domain = strstr($mail, '@');
$domain = substr($domain, 1);
if (strpos($domain, '>')) {
$domain = str_replace('>', '', $domain);
$domain = $idn->encode($domain) . '>';
$domain = $idna->convert($domain) . '>';
}
else {
$domain = $idn->encode($domain);
$domain = $idna->convert($domain);
}
$mail = "{$user}@{$domain}";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment