{"record":{"id":"93752f434dc61f48","repo":"phacility/phabricator","slug":"specify-one-or-more-users-to-send-a-message-to-wit","errorCode":null,"errorMessage":"Specify one or more users to send a message to with \"--to\" and/or \"--cc\".","messagePattern":"Specify one or more users to send a message to with \"--to\" and/or \"--cc\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php","lineNumber":107,"sourceCode":"\n    $from = $args->getArg('from');\n    if ($from) {\n      $user = id(new PhabricatorPeopleQuery())\n        ->setViewer($viewer)\n        ->withUsernames(array($from))\n        ->executeOne();\n      if (!$user) {\n        throw new PhutilArgumentUsageException(\n          pht(\"No such user '%s' exists.\", $from));\n      }\n      $from = $user;\n    }\n\n    $tos = $args->getArg('to');\n    $ccs = $args->getArg('cc');\n\n    if (!$tos && !$ccs) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify one or more users to send a message to with \"--to\" and/or '.\n          '\"--cc\".'));\n    }\n\n    $names = array_merge($tos, $ccs);\n    $users = id(new PhabricatorPeopleQuery())\n      ->setViewer($viewer)\n      ->withUsernames($names)\n      ->execute();\n    $users = mpull($users, null, 'getUsername');\n\n    $raw_tos = array();\n    foreach ($tos as $key => $username) {\n      // If the recipient has an \"@\" in any noninitial position, treat this as\n      // a raw email address.\n      if (preg_match('/.@/', $username)) {\n        $raw_tos[] = $username;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php#L89-L125","documentation":"`bin/mail send-test` requires at least one recipient and rejects the invocation when both `--to` and `--cc` are empty. The recipient pool is built exclusively from these two repeatable flags, so with neither present there is nobody to deliver to and the workflow throws PhutilArgumentUsageException before constructing the mail.","triggerScenarios":"Invoking send-test with only mailer/subject/body flags; a scripted call whose recipient variable expanded to an empty list; passing --to with an empty string value.","commonSituations":"Mailer connectivity tests where the author focuses on --mailer and forgets recipients; automation templates that forgot the recipient flags.","solutions":["Add at least one recipient: `--to <username>` or `--cc <username>` (both repeatable).","To reach an address outside Phabricator, pass a raw email (contains '@') such as `--to user@example.com`.","In scripts, assert the recipient array is non-empty before shelling out to the workflow."],"exampleFix":"// before\n$ bin/mail send-test --subject hi\n// Exception: Specify one or more users to send a message to with \"--to\" and/or \"--cc\".\n\n// after\n$ bin/mail send-test --subject hi --to alincoln","handlingStrategy":"validation","validationCode":"// Assert recipients before shelling out:\nif (empty($to_list) && empty($cc_list)) {\n  fwrite(STDERR, \"send-test requires at least one --to or --cc recipient.\\n\");\n  exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --to/--cc as required in any send-test wrapper script.","Remember --to accepts raw email addresses (with '@') as well as usernames.","Fail fast in automation on empty recipient arrays."],"tags":["php","phabricator","cli","argument-validation","mail"],"backgroundTag":"missing-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}