mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
IDNA support (beta)
This commit is contained in:
parent
0ca00dec40
commit
e82108ac85
31 changed files with 3839 additions and 308 deletions
|
|
@ -39,7 +39,7 @@ class Email
|
|||
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->sEmail = \trim($sEmail);
|
||||
$this->sEmail = \MailSo\Base\Utils::IdnToAscii(\trim($sEmail), true);
|
||||
$this->sDisplayName = \trim($sDisplayName);
|
||||
$this->sRemark = \trim($sRemark);
|
||||
}
|
||||
|
|
@ -176,6 +176,7 @@ class Email
|
|||
}
|
||||
|
||||
$sEmail = \trim(\trim($sEmail), '<>');
|
||||
|
||||
$sName = \trim(\trim($sName), '"');
|
||||
$sName = \trim($sName, '\'');
|
||||
$sComment = \trim(\trim($sComment), '()');
|
||||
|
|
@ -188,11 +189,13 @@ class Email
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetEmail()
|
||||
public function GetEmail($bIdn = false)
|
||||
{
|
||||
return $this->sEmail;
|
||||
return $bIdn ? \MailSo\Base\Utils::IdnToUtf8($this->sEmail) : $this->sEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,31 +219,36 @@ class Email
|
|||
*/
|
||||
public function GetAccountName()
|
||||
{
|
||||
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->sEmail);
|
||||
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->GetEmail(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetDomain()
|
||||
public function GetDomain($bIdn = false)
|
||||
{
|
||||
return \MailSo\Base\Utils::GetDomainFromEmail($this->sEmail);
|
||||
return \MailSo\Base\Utils::GetDomainFromEmail($this->GetEmail($bIdn));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ToArray()
|
||||
public function ToArray($bIdn = false)
|
||||
{
|
||||
return array($this->sDisplayName, $this->sEmail, $this->sRemark);
|
||||
return array($this->sDisplayName, $this->GetEmail($bIdn), $this->sRemark);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false)
|
||||
public function ToString($bConvertSpecialsName = false, $bIdn = false)
|
||||
{
|
||||
$sReturn = '';
|
||||
|
||||
|
|
@ -263,8 +271,7 @@ class Email
|
|||
|
||||
if (0 < \strlen($this->sEmail))
|
||||
{
|
||||
$sReturn = $this->sEmail;
|
||||
|
||||
$sReturn = $this->GetEmail($bIdn);
|
||||
if (0 < \strlen($sDisplayName.$sRemark))
|
||||
{
|
||||
$sReturn = $sDisplayName.' <'.$sReturn.'> '.$sRemark;
|
||||
|
|
|
|||
|
|
@ -100,16 +100,17 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false)
|
||||
public function ToString($bConvertSpecialsName = false, $bIdn = false)
|
||||
{
|
||||
$aReturn = $aEmails = array();
|
||||
$aEmails =& $this->GetAsArray();
|
||||
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
{
|
||||
$aReturn[] = $oEmail->ToString($bConvertSpecialsName);
|
||||
$aReturn[] = $oEmail->ToString($bConvertSpecialsName, $bIdn);
|
||||
}
|
||||
|
||||
return \implode(', ', $aReturn);
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ class Header
|
|||
$oEmailCollection = \MailSo\Mime\EmailCollection::NewInstance($this->sFullValue);
|
||||
if ($oEmailCollection && 0 < $oEmailCollection->Count())
|
||||
{
|
||||
$sResult = $oEmailCollection->ToString(true);
|
||||
$sResult = $oEmailCollection->ToString(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeader
|
||||
* @param string $sHeaderName
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue