1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,16 @@ public function execute(PhutilArgumentParser $args) {
93
93
->execute ();
94
94
$ users = mpull ($ users , null , 'getUsername ' );
95
95
96
+ $ raw_tos = array ();
96
97
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
+
97
106
if (empty ($ users [$ username ])) {
98
107
throw new PhutilArgumentUsageException (
99
108
pht ("No such user '%s' exists. " , $ username ));
@@ -122,13 +131,20 @@ public function execute(PhutilArgumentParser $args) {
122
131
$ body = file_get_contents ('php://stdin ' );
123
132
124
133
$ mail = id (new PhabricatorMetaMTAMail ())
125
- ->addTos ($ tos )
126
134
->addCCs ($ ccs )
127
135
->setSubject ($ subject )
128
136
->setBody ($ body )
129
137
->setIsBulk ($ is_bulk )
130
138
->setMailTags ($ tags );
131
139
140
+ if ($ tos ) {
141
+ $ mail ->addTos ($ tos );
142
+ }
143
+
144
+ if ($ raw_tos ) {
145
+ $ mail ->addRawTos ($ raw_tos );
146
+ }
147
+
132
148
if ($ args ->getArg ('html ' )) {
133
149
$ mail ->setBody (
134
150
pht (
0 commit comments