Allow "bin/mail send-test" to accept raw email addresses via "--to"
Summary: Ref T12372. This supports testing the `wordwrap()` patch discussed in that task. Test Plan: - Ran `bin/mail send-test --to email@domain.com` - Ran `bin/mail send-test --to username` Reviewers: chad, lvital Reviewed By: lvital Maniphest Tasks: T12372 Differential Revision: https://secure.phabricator.com/D17489
This commit is contained in:
parent
d73df58cc6
commit
2b5bf4b911
|
@ -93,7 +93,16 @@ final class PhabricatorMailManagementSendTestWorkflow
|
||||||
->execute();
|
->execute();
|
||||||
$users = mpull($users, null, 'getUsername');
|
$users = mpull($users, null, 'getUsername');
|
||||||
|
|
||||||
|
$raw_tos = array();
|
||||||
foreach ($tos as $key => $username) {
|
foreach ($tos as $key => $username) {
|
||||||
|
// If the recipient has an "@" in any noninitial position, treat this as
|
||||||
|
// a raw email address.
|
||||||
|
if (preg_match('/.@/', $username)) {
|
||||||
|
$raw_tos[] = $username;
|
||||||
|
unset($tos[$key]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($users[$username])) {
|
if (empty($users[$username])) {
|
||||||
throw new PhutilArgumentUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
pht("No such user '%s' exists.", $username));
|
pht("No such user '%s' exists.", $username));
|
||||||
|
@ -122,13 +131,20 @@ final class PhabricatorMailManagementSendTestWorkflow
|
||||||
$body = file_get_contents('php://stdin');
|
$body = file_get_contents('php://stdin');
|
||||||
|
|
||||||
$mail = id(new PhabricatorMetaMTAMail())
|
$mail = id(new PhabricatorMetaMTAMail())
|
||||||
->addTos($tos)
|
|
||||||
->addCCs($ccs)
|
->addCCs($ccs)
|
||||||
->setSubject($subject)
|
->setSubject($subject)
|
||||||
->setBody($body)
|
->setBody($body)
|
||||||
->setIsBulk($is_bulk)
|
->setIsBulk($is_bulk)
|
||||||
->setMailTags($tags);
|
->setMailTags($tags);
|
||||||
|
|
||||||
|
if ($tos) {
|
||||||
|
$mail->addTos($tos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($raw_tos) {
|
||||||
|
$mail->addRawTos($raw_tos);
|
||||||
|
}
|
||||||
|
|
||||||
if ($args->getArg('html')) {
|
if ($args->getArg('html')) {
|
||||||
$mail->setBody(
|
$mail->setBody(
|
||||||
pht(
|
pht(
|
||||||
|
|
Loading…
Reference in a new issue