mirror of
https://github.com/retailcrm/transparent-email.git
synced 2024-11-21 21:06:04 +03:00
add ICloud Service
This commit is contained in:
parent
b7a9a721ea
commit
50e1da498e
11
README.md
11
README.md
@ -17,6 +17,7 @@ To detect multi-accounts on your website.
|
||||
* [33mail.com](https://www.33mail.com)
|
||||
* [outlook.com](http://outlook.com)
|
||||
* [yahoo.com](http://mail.yahoo.com)
|
||||
* [icloud.com](https://www.icloud.com/)
|
||||
* [yandex.ru](https://yandex.ru/)
|
||||
* [mail.ru](https://mail.ru/)
|
||||
|
||||
@ -63,11 +64,11 @@ which actually does not exist.
|
||||
In official [documentation](https://yandex.com/support/mail/web/preferences/about-sender/additional-addresses.html) you can find some use-cases about aliases usage.
|
||||
|
||||
## Mail.ru
|
||||
There's no official documentation about aliases here, but you can create them with these ways:
|
||||
Mail.ru service uses following aliases:
|
||||
* `janedoe+alias@mail.ru` will be redirected to `janedoe@mail.ru`
|
||||
* `janeDoe@MAIL.RU` will be redirected to `janedoe@mail.ru`
|
||||
|
||||
Also, it's possible to create aliases in the settings of Mail.ru, for example, like these ones:
|
||||
* `janeDoe@list.ru` will be redirected to `janedoe@mail.ru`
|
||||
* `janeDoe@inbox.ru` will be redirected to `janedoe@mail.ru`
|
||||
* `janeDoe@bk.ru` will be redirected to `janedoe@mail.ru`
|
||||
## Icloud.com
|
||||
Icloud.com service uses following aliases:
|
||||
* `janedoe+alias@icloud.com` will be redirected to `janedoe@icloud.com`
|
||||
* `janeDoe@ICLOUD.COM` will be redirected to `janedoe@icloud.com`
|
21
src/Services/IcloudCom.php
Normal file
21
src/Services/IcloudCom.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
use bkrukowski\TransparentEmail\Emails\EditableEmail;
|
||||
use bkrukowski\TransparentEmail\Emails\EmailInterface;
|
||||
|
||||
class IcloudCom implements ServiceInterface
|
||||
{
|
||||
public function getPrimaryEmail(EmailInterface $email) : EmailInterface
|
||||
{
|
||||
return (new EditableEmail($email))
|
||||
->removeSuffixAlias('+')
|
||||
->lowerCaseLocalPartIf(true);
|
||||
}
|
||||
|
||||
public function isSupported(EmailInterface $email) : bool
|
||||
{
|
||||
return in_array($email->getDomain(), ['icloud.com']);
|
||||
}
|
||||
}
|
@ -13,26 +13,11 @@ class MailRu implements ServiceInterface
|
||||
{
|
||||
return (new EditableEmail($email))
|
||||
->removeSuffixAlias('+')
|
||||
->lowerCaseLocalPartIf(true)
|
||||
->setDomain($this->mapDomain($email->getDomain()));
|
||||
->lowerCaseLocalPartIf(true);
|
||||
}
|
||||
|
||||
public function isSupported(EmailInterface $email) : bool
|
||||
{
|
||||
return in_array($email->getDomain(), ['mail.ru', 'list.ru', 'inbox.ru', 'bk.ru']);
|
||||
}
|
||||
|
||||
protected function getDomainMapping() : array
|
||||
{
|
||||
return [
|
||||
'list.ru' => 'mail.ru',
|
||||
'inbox.ru' => 'mail.ru',
|
||||
'bk.ru' => 'mail.ru',
|
||||
];
|
||||
}
|
||||
|
||||
private function mapDomain(string $domain) : string
|
||||
{
|
||||
return $this->getDomainMapping()[$domain] ?? $domain;
|
||||
return in_array($email->getDomain(), ['mail.ru']);
|
||||
}
|
||||
}
|
@ -18,6 +18,6 @@ class OutlookCom implements ServiceInterface
|
||||
|
||||
public function isSupported(EmailInterface $email) : bool
|
||||
{
|
||||
return in_array($email->getDomain(), ['outlook.com', 'hotmail.com'], true);
|
||||
return in_array($email->getDomain(), ['outlook.com', 'hotmail.com', 'live.com', 'msn.com'], true);
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ namespace bkrukowski\TransparentEmail;
|
||||
|
||||
use bkrukowski\TransparentEmail\Services\AppsGoogleCom;
|
||||
use bkrukowski\TransparentEmail\Services\GmailCom;
|
||||
use bkrukowski\TransparentEmail\Services\IcloudCom;
|
||||
use bkrukowski\TransparentEmail\Services\MailRu;
|
||||
use bkrukowski\TransparentEmail\Services\OutlookCom;
|
||||
use bkrukowski\TransparentEmail\Services\TlenPl;
|
||||
@ -42,6 +43,7 @@ class TransparentEmailFactory
|
||||
AppsGoogleCom::class,
|
||||
YandexRu::class,
|
||||
MailRu::class,
|
||||
IcloudCom::class
|
||||
];
|
||||
}
|
||||
}
|
49
tests/Services/IcloudComTest.php
Normal file
49
tests/Services/IcloudComTest.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\TransparentEmail\Emails\Email;
|
||||
use bkrukowski\TransparentEmail\Services\IcloudCom;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IcloudComTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerGetPrimaryEmail
|
||||
*
|
||||
* @param string $inputEmail
|
||||
* @param string $outputEmail
|
||||
*/
|
||||
public function testGetPrimaryEmail(string $inputEmail, string $outputEmail)
|
||||
{
|
||||
$this->assertEquals($outputEmail, (new IcloudCom())->getPrimaryEmail(new Email($inputEmail)));
|
||||
}
|
||||
|
||||
public function providerGetPrimaryEmail() : array
|
||||
{
|
||||
return [
|
||||
['foobar@ICLOUD.COM', 'foobar@icloud.com'],
|
||||
['foobar+alias@icloud.com', 'foobar@icloud.com'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsSupported
|
||||
*
|
||||
* @param string $domain
|
||||
* @param bool $result
|
||||
*/
|
||||
public function testIsSupported(string $domain, bool $result)
|
||||
{
|
||||
$this->assertSame($result, (new IcloudCom())->isSupported(new Email('Jane.Doe@' . $domain)));
|
||||
}
|
||||
|
||||
public function providerIsSupported() : array
|
||||
{
|
||||
return [
|
||||
['icloud.com', true],
|
||||
['ICLOUD.COM', true],
|
||||
['i.cloud.com', false],
|
||||
];
|
||||
}
|
||||
}
|
@ -27,9 +27,6 @@ class MailRuTest extends TestCase
|
||||
['foobar@MAIL.RU', 'foobar@mail.ru'],
|
||||
['fOObar@MaiL.Ru', 'foobar@mail.ru'],
|
||||
['foobar+alias@mail.ru', 'foobar@mail.ru'],
|
||||
['foobar@list.ru', 'foobar@mail.ru'],
|
||||
['foobar@inbox.ru', 'foobar@mail.ru'],
|
||||
['foobar@bk.ru', 'foobar@mail.ru'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -48,9 +45,6 @@ class MailRuTest extends TestCase
|
||||
{
|
||||
return [
|
||||
['mail.ru', true],
|
||||
['list.ru', true],
|
||||
['inbox.ru', true],
|
||||
['bk.ru', true],
|
||||
['mail.RU', true],
|
||||
['MAIL.RU', true],
|
||||
['ma.il.ru', false],
|
||||
|
@ -27,7 +27,11 @@ class OutlookComTest extends TestCase
|
||||
['outlook.com', true],
|
||||
['Outlook.Com', true],
|
||||
['hotmail.com', true],
|
||||
['msn.com', true],
|
||||
['live.com', true],
|
||||
['HotMail.COM', true],
|
||||
['Msn.COM', true],
|
||||
['LIve.COM', true],
|
||||
['gmail.com', false],
|
||||
['tlen.pl', false],
|
||||
];
|
||||
@ -52,6 +56,8 @@ class OutlookComTest extends TestCase
|
||||
['Jane.Doe@Outlook.Com', 'jane.doe@outlook.com'],
|
||||
['Jane.Doe+alias@OUTLOOK.COM', 'jane.doe@outlook.com'],
|
||||
['Jane.Doe+Hotmail@hotmail.com', 'jane.doe@hotmail.com'],
|
||||
['Jane.Doe+Hotmail@live.com', 'jane.doe@live.com'],
|
||||
['Jane.Doe+Hotmail@msn.com', 'jane.doe@msn.com'],
|
||||
];
|
||||
}
|
||||
}
|
@ -48,6 +48,9 @@ class TransparentEmailTest extends TestCase
|
||||
[new TransparentEmail($emptyServiceCollector), 'John.Doe@example.com', 'John.Doe@example.com', true],
|
||||
[(new TransparentEmailFactory())->createDefault(), 'John.Doe@gmail.com', 'johndoe@gmail.com', true],
|
||||
[(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'],
|
||||
[(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@live.com', 'jane.doe@live.com'],
|
||||
[(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@msn.com', 'jane.doe@msn.com'],
|
||||
[(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@outlook.com', 'jane.doe@outlook.com'],
|
||||
[(new TransparentEmailFactory())->createDefault(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe@yahoo.com'],
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user