Page MenuHomePhabricator

email2user.php

Authored By
jimh
Dec 13 2016, 3:28 AM
Size
1 KB
Referenced Files
None
Subscribers
None

email2user.php

Had to do a little freehand scribbling to remove some company stuff and extra distracting functionality, but I'm pretty sure this will still work. Execute the code thus:
$ php email2uer.php jdoe
It should just come back with something like:
johndoe@yourcompany.com
(or warn you that this user id isn't in the Phabricator SQL database...)
Then use it however you'd like. Thanks Chad and staff for your patience.
========================================
<?php
$root = "/Users/yourinstalldir/phabricator";
require_once $root.'/scripts/__init_script__.php';
if ($argc !== 2) {
print "Usage mail2user.php <username>";
exit(1);
}
$username = $argv[1];
$existing_user = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
$username);
if (!$existing_user) {
print "*** ERROR - username $username is not a valid Phabricator user.";
return 1;
}
$PHID = $existing_user->getPHID();
$existing_email = id(new PhabricatorUserEmail())->loadOneWhere(
'userPHID = %s',
$PHID);
$address = $existing_email->getAddress();
print "$address";
return 0;
?>

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
370202
Default Alt Text
email2user.php (1 KB)

Event Timeline