本文整理汇总了PHP中Support::saveRoutedEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Support::saveRoutedEmail方法的具体用法?PHP Support::saveRoutedEmail怎么用?PHP Support::saveRoutedEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Support
的用法示例。
在下文中一共展示了Support::saveRoutedEmail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route_emails
/**
* Routes an email to the correct issue.
*
* @param string $full_message The full email message, including headers
* @return mixed true or array(ERROR_CODE, ERROR_STRING) in case of failure
*/
public static function route_emails($full_message)
{
// need some validation here
if (empty($full_message)) {
return array(self::EX_NOINPUT, ev_gettext('Error: The email message was empty') . ".\n");
}
// save the full message for logging purposes
Support::saveRoutedEmail($full_message);
// check if the email routing interface is even supposed to be enabled
$setup = Setup::get();
if ($setup['email_routing']['status'] != 'enabled') {
return array(self::EX_CONFIG, ev_gettext('Error: The email routing interface is disabled.') . "\n");
}
if (empty($setup['email_routing']['address_prefix'])) {
return array(self::EX_CONFIG, ev_gettext('Error: Please configure the email address prefix.') . "\n");
}
if (empty($setup['email_routing']['address_host'])) {
return array(self::EX_CONFIG, ev_gettext('Error: Please configure the email address domain.') . "\n");
}
// associate routed emails to the internal system account
$sys_account = User::getNameEmail(APP_SYSTEM_USER_ID);
if (empty($sys_account['usr_email'])) {
return array(self::EX_CONFIG, ev_gettext('Error: The associated user for the email routing interface needs to be set.') . "\n");
}
unset($sys_account);
// join the Content-Type line (for easier parsing?)
if (preg_match('/^boundary=/m', $full_message)) {
$pattern = "#(Content-Type: multipart/.+); ?\r?\n(boundary=.*)\$#im";
$replacement = '$1; $2';
$full_message = preg_replace($pattern, $replacement, $full_message);
}
// remove the reply-to: header
if (preg_match('/^reply-to:.*/im', $full_message)) {
$full_message = preg_replace("/^(reply-to:).*\n/im", '', $full_message, 1);
}
AuthCookie::setAuthCookie(APP_SYSTEM_USER_ID);
$structure = Mime_Helper::decode($full_message, true, true);
// find which issue ID this email refers to
if (isset($structure->headers['to'])) {
$issue_id = self::getMatchingIssueIDs($structure->headers['to'], 'email');
}
// we need to try the Cc header as well
if (empty($issue_id) and isset($structure->headers['cc'])) {
$issue_id = self::getMatchingIssueIDs($structure->headers['cc'], 'email');
}
if (empty($issue_id)) {
return array(self::EX_DATAERR, ev_gettext('Error: The routed email had no associated Eventum issue ID or had an invalid recipient address.') . "\n");
}
$issue_prj_id = Issue::getProjectID($issue_id);
if (empty($issue_prj_id)) {
return array(self::EX_DATAERR, ev_gettext('Error: The routed email had no associated Eventum issue ID or had an invalid recipient address.') . "\n");
}
$email_account_id = Email_Account::getEmailAccount($issue_prj_id);
if (empty($email_account_id)) {
return array(self::EX_CONFIG, ev_gettext('Error: Please provide the email account ID.') . "\n");
}
$body = $structure->body;
// hack for clients that set more then one from header
if (is_array($structure->headers['from'])) {
$structure->headers['from'] = $structure->headers['from'][0];
}
// associate the email to the issue
$parts = array();
Mime_Helper::parse_output($structure, $parts);
// get the sender's email address
$sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from']));
// strip out the warning message sent to staff users
if ($setup['email_routing']['status'] == 'enabled' && $setup['email_routing']['warning']['status'] == 'enabled') {
$full_message = Mail_Helper::stripWarningMessage($full_message);
$body = Mail_Helper::stripWarningMessage($body);
}
$prj_id = Issue::getProjectID($issue_id);
AuthCookie::setAuthCookie(APP_SYSTEM_USER_ID);
AuthCookie::setProjectCookie($prj_id);
if (Mime_Helper::hasAttachments($structure)) {
$has_attachments = 1;
} else {
$has_attachments = 0;
}
// remove certain CC addresses
if (!empty($structure->headers['cc']) && $setup['smtp']['save_outgoing_email'] == 'yes') {
$ccs = explode(',', @$structure->headers['cc']);
foreach ($ccs as $i => $address) {
if (Mail_Helper::getEmailAddress($address) == $setup['smtp']['save_address']) {
unset($ccs[$i]);
}
}
$structure->headers['cc'] = implode(', ', $ccs);
}
// Remove excess Re's
$structure->headers['subject'] = Mail_Helper::removeExcessRe(@$structure->headers['subject'], true);
$t = array('issue_id' => $issue_id, 'ema_id' => $email_account_id, 'message_id' => @$structure->headers['message-id'], 'date' => Date_Helper::getCurrentDateGMT(), 'from' => @$structure->headers['from'], 'to' => @$structure->headers['to'], 'cc' => @$structure->headers['cc'], 'subject' => @$structure->headers['subject'], 'body' => @$body, 'full_email' => @$full_message, 'has_attachment' => $has_attachments, 'headers' => @$structure->headers);
// automatically associate this incoming email with a customer
if (CRM::hasCustomerIntegration($prj_id)) {
//.........这里部分代码省略.........
示例2: route_emails
/**
* Routes an email to the correct issue.
*
* @param string $full_message The full email message, including headers
* @param integer $email_account_id The ID of the email account this email should be routed too. If empty this method will try to figure it out
*/
function route_emails($full_message, $email_account_id = 0)
{
global $HTTP_POST_VARS;
// save the full message for logging purposes
Support::saveRoutedEmail($full_message);
if (preg_match("/^(boundary=).*/m", $full_message)) {
$pattern = "/(Content-Type: multipart\\/)(.+); ?\r?\n(boundary=)(.*)\$/im";
$replacement = '$1$2; $3$4';
$full_message = preg_replace($pattern, $replacement, $full_message);
}
// associate routed emails to the internal system account
$sys_account = User::getNameEmail(APP_SYSTEM_USER_ID);
$associated_user = $sys_account['usr_email'];
// need some validation here
if (empty($full_message)) {
return array(66, "Error: The email message was empty.\n");
}
if (empty($associated_user)) {
return array(78, "Error: The associated user for the email routing interface needs to be set.\n");
}
//
// DON'T EDIT ANYTHING BELOW THIS LINE
//
// remove the reply-to: header
if (preg_match("/^(reply-to:).*/im", $full_message)) {
$full_message = preg_replace("/^(reply-to:).*\n/im", '', $full_message, 1);
}
// check for magic cookie
if (Mail_API::hasMagicCookie($full_message)) {
// strip the magic cookie
$full_message = Mail_API::stripMagicCookie($full_message);
$has_magic_cookie = true;
} else {
$has_magic_cookie = false;
}
Auth::createFakeCookie(APP_SYSTEM_USER_ID);
// check if the email routing interface is even supposed to be enabled
$setup = Setup::load();
if ($setup['email_routing']['status'] != 'enabled') {
return array(78, "Error: The email routing interface is disabled.\n");
}
$prefix = $setup['email_routing']['address_prefix'];
// escape plus signs so 'issue+1@example.com' becomes a valid routing address
$prefix = str_replace('+', '\\+', $prefix);
$mail_domain = quotemeta($setup['email_routing']['address_host']);
$mail_domain_alias = quotemeta(@$setup['email_routing']['host_alias']);
if (!empty($mail_domain_alias)) {
$mail_domain = "(?:" . $mail_domain . "|" . $mail_domain_alias . ")";
}
if (empty($prefix)) {
return array(78, "Error: Please configure the email address prefix.\n");
}
if (empty($mail_domain)) {
return array(78, "Error: Please configure the email address domain.\n");
}
$structure = Mime_Helper::decode($full_message, true, true);
// find which issue ID this email refers to
@preg_match("/{$prefix}(\\d*)@{$mail_domain}/i", $structure->headers['to'], $matches);
@($issue_id = $matches[1]);
// validation is always a good idea
if (empty($issue_id)) {
// we need to try the Cc header as well
@preg_match("/{$prefix}(\\d*)@{$mail_domain}/i", $structure->headers['cc'], $matches);
if (!empty($matches[1])) {
$issue_id = $matches[1];
} else {
return array(65, "Error: The routed email had no associated Eventum issue ID or had an invalid recipient address.\n");
}
}
if (empty($email_account_id)) {
$issue_prj_id = Issue::getProjectID($issue_id);
if (empty($issue_prj_id)) {
return array(65, "Error: The routed email had no associated Eventum issue ID or had an invalid recipient address.\n");
}
$email_account_id = Email_Account::getEmailAccount($issue_prj_id);
}
if (empty($email_account_id)) {
return array(78, "Error: Please provide the email account ID.\n");
}
$body = Mime_Helper::getMessageBody($structure);
// hack for clients that set more then one from header
if (is_array($structure->headers['from'])) {
$structure->headers['from'] = $structure->headers['from'][0];
}
// associate the email to the issue
$parts = array();
Mime_Helper::parse_output($structure, $parts);
// get the sender's email address
$sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
// strip out the warning message sent to staff users
if ($setup['email_routing']['status'] == 'enabled' && $setup['email_routing']['warning']['status'] == 'enabled') {
$full_message = Mail_API::stripWarningMessage($full_message);
$body = Mail_API::stripWarningMessage($body);
}
//.........这里部分代码省略.........