Skip to content

Commit 2b5bf4b

Browse files
author
epriestley
committedMar 10, 2017
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
1 parent d73df58 commit 2b5bf4b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed
 

‎src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,16 @@ public function execute(PhutilArgumentParser $args) {
9393
->execute();
9494
$users = mpull($users, null, 'getUsername');
9595

96+
$raw_tos = array();
9697
foreach ($tos as $key => $username) {
98+
// If the recipient has an "@" in any noninitial position, treat this as
99+
// a raw email address.
100+
if (preg_match('/.@/', $username)) {
101+
$raw_tos[] = $username;
102+
unset($tos[$key]);
103+
continue;
104+
}
105+
97106
if (empty($users[$username])) {
98107
throw new PhutilArgumentUsageException(
99108
pht("No such user '%s' exists.", $username));
@@ -122,13 +131,20 @@ public function execute(PhutilArgumentParser $args) {
122131
$body = file_get_contents('php://stdin');
123132

124133
$mail = id(new PhabricatorMetaMTAMail())
125-
->addTos($tos)
126134
->addCCs($ccs)
127135
->setSubject($subject)
128136
->setBody($body)
129137
->setIsBulk($is_bulk)
130138
->setMailTags($tags);
131139

140+
if ($tos) {
141+
$mail->addTos($tos);
142+
}
143+
144+
if ($raw_tos) {
145+
$mail->addRawTos($raw_tos);
146+
}
147+
132148
if ($args->getArg('html')) {
133149
$mail->setBody(
134150
pht(

0 commit comments

Comments
 (0)
Failed to load comments.