/**
  * @return Tracker_Artifact_MailGateway_IncomingMessage
  */
 public function build(array $raw_mail)
 {
     if (!isset($raw_mail['headers']['references'])) {
         throw new Tracker_Artifact_MailGateway_InvalidMailHeadersException();
     }
     preg_match(Tracker_Artifact_MailGateway_RecipientFactory::EMAIL_PATTERN, $raw_mail['headers']['references'], $matches);
     $recipient = $this->recipient_factory->getFromEmail($matches[0]);
     $subject = $raw_mail['headers']['subject'];
     $body = $raw_mail['body'];
     $incoming_message = new Tracker_Artifact_MailGateway_IncomingMessage($raw_mail['headers'], $subject, $body, $recipient->getUser(), $recipient->getArtifact()->getTracker(), $recipient->getArtifact());
     return $incoming_message;
 }
 /**
  * @return Tracker_Artifact_MailGateway_RecipientFactory
  */
 protected function getRecipientFactory()
 {
     return Tracker_Artifact_MailGateway_RecipientFactory::build();
 }
Example #3
0
 private function getRecipient(stdClass $structure)
 {
     preg_match(Tracker_Artifact_MailGateway_RecipientFactory::EMAIL_PATTERN, $structure->headers['references'], $matches);
     return $this->recipient_factory->getFromEmail($matches[0]);
 }
Example #4
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */
require 'pre.php';
$fd = fopen("php://stdin", "r");
$raw_mail = "";
while (!feof($fd)) {
    $raw_mail .= fread($fd, 1024);
}
fclose($fd);
$logger = new BackendLogger();
$logger->info("Entering email gateway");
$recipient_factory = Tracker_Artifact_MailGateway_RecipientFactory::build();
$parser = new Tracker_Artifact_MailGateway_Parser($recipient_factory);
$citation_sripper = new Tracker_Artifact_MailGateway_CitationStripper();
$mailgateway = new Tracker_Artifact_MailGateway_MailGateway($parser, $citation_sripper, $logger);
try {
    $mailgateway->process($raw_mail);
} catch (Exception $e) {
    $logger->error($e->getMessage());
}
$logger->info("End email gateway");