Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2894030
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/scripts/__init_env__.php b/scripts/__init_env__.php
index 8925464937..faf5fedcea 100644
--- a/scripts/__init_env__.php
+++ b/scripts/__init_env__.php
@@ -1,40 +1,42 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$include_path = ini_get('include_path');
ini_set('include_path', $include_path.':'.dirname(__FILE__).'/../../');
require_once dirname(dirname(__FILE__)).'/conf/__init_conf__.php';
-$env = getenv('PHABRICATOR_ENV');
+$env = isset($_SERVER['PHABRICATOR_ENV'])
+ ? $_SERVER['PHABRICATOR_ENV']
+ : getenv('PHABRICATOR_ENV');
if (!$env) {
echo "Define PHABRICATOR_ENV before running this script.\n";
exit(1);
}
$conf = phabricator_read_config_file($env);
$conf['phabricator.env'] = $env;
phutil_require_module('phabricator', 'infrastructure/env');
PhabricatorEnv::setEnvConfig($conf);
phutil_load_library('arcanist/src');
foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
phutil_load_library($library);
}
diff --git a/scripts/mail/mail_handler.php b/scripts/mail/mail_handler.php
index f2f5412e75..001a03491b 100755
--- a/scripts/mail/mail_handler.php
+++ b/scripts/mail/mail_handler.php
@@ -1,54 +1,58 @@
#!/usr/bin/php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+if ($argc > 1) {
+ $_SERVER['PHABRICATOR_ENV'] = $argv[1];
+}
+
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
require_once $root.'/externals/mimemailparser/MimeMailParser.class.php';
phutil_require_module(
'phabricator',
'applications/metamta/storage/receivedmail');
phutil_require_module(
'phabricator',
'applications/files/storage/file');
$parser = new MimeMailParser();
$parser->setText(file_get_contents('php://stdin'));
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders($parser->getHeaders());
$received->setBodies(array(
'text' => $parser->getMessageBody('text'),
'html' => $parser->getMessageBody('html'),
));
$attachments = array();
foreach ($received->getAttachments() as $attachment) {
$file = PhabricatorFile::newFromFileData(
$attachment->getContent(),
array(
'name' => $attachment->getFilename(),
));
$attachments[] = $file->getPHID();
}
$received->setAttachments($attachments);
$received->save();
$received->processReceivedMail();
diff --git a/src/docs/configuring_inbound_email.diviner b/src/docs/configuring_inbound_email.diviner
index 900e87ae73..f3ead1557a 100644
--- a/src/docs/configuring_inbound_email.diviner
+++ b/src/docs/configuring_inbound_email.diviner
@@ -1,65 +1,65 @@
@title Configuring Inbound Email
@group config
This document contains instructions for configuring inbound email, so users
may update Differential and Maniphest by replying to messages.
= Preamble =
This is extremely difficult to configure correctly. This is doubly true if
you use sendmail.
= Installing Mailparse =
You need to install the PECL mailparse extension. In theory, you can do that
with:
$ sudo pecl install mailparse
You may run into an error like "needs mbstring". If so, try:
$ sudo yum install php-mbstring # or equivalent
$ sudo pecl install -n mailparse
If you get a linker error like this:
COUNTEREXAMPLE
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib64/php/modules/mailparse.so' - /usr/lib64/php/modules/mailparse.so:
undefined symbol: mbfl_name2no_encoding in Unknown on line 0
...you need to edit your php.ini file so that mbstring.so is loaded **before**
mailparse.so. This is not the default if you have individual files in
##php.d/##.
= Configuring Sendmail =
Sendmail is very difficult to configure. First, you need to configure it for
your domain so that mail can be delievered correctly. In broad strokes, this
probably means something like this:
- add an MX record;
- make sendmail listen on external interfaces;
- open up port 25 if necessary (e.g., in your EC2 security policy);
- add your host to /etc/mail/local-host-names; and
- restart sendmail.
Now, you can actually configure sendmail to deliver to Phabricator. In
##/etc/aliases##, add an entry like this:
- phabricator: "| PHABRICATOR_ENV=<ENV> /path/to/phabricator/scripts/mail/mail_handler.php"
+ phabricator: "| /path/to/phabricator/scripts/mail/mail_handler.php <ENV>"
...where <ENV> is the PHABRICATOR_ENV the script should run under. Run
##sudo newaliases##. Now you likely need to symlink this script into
##/etc/smrsh/##:
sudo ln -s /path/to/phabricator/scripts/mail/mail_handler.php /etc/smrsh/
Finally, edit ##/etc/mail/virtusertable## and add an entry like this:
@yourdomain.com phabricator@localhost
That will forward all mail to @yourdomain.com to the Phabricator processing
script. Run ##sudo /etc/mail/make## or similar and then restart sendmail with
##sudo /etc/init.d/sendmail restart##
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 19:16 (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127876
Default Alt Text
(5 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment