1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 02:02:41 +01:00
phorge-phorge/src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php

38 lines
811 B
PHP
Raw Normal View History

2013-05-14 19:57:41 +02:00
<?php
abstract class PhabricatorObjectMailReceiver extends PhabricatorMailReceiver {
abstract protected function getObjectPattern();
final public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
$regexp = $this->getAddressRegexp();
foreach ($mail->getToAddresses() as $address) {
$address = self::stripMailboxPrefix($address);
$local = id(new PhutilEmailAddress($address))->getLocalPart();
if (preg_match($regexp, $local)) {
return true;
}
}
return false;
}
private function getAddressRegexp() {
$pattern = $this->getObjectPattern();
$regexp =
'(^'.
'(?P<pattern>'.$pattern.')'.
'\\+'.
'(?P<sender>\w+)'.
'\\+'.
'(?P<hash>[a-f0-9]{16})'.
'$)U';
return $regexp;
}
}