Example #1
0
/**
 * Store email in queue for sending
 *
 * @param string  $p_recipient Email recipient address.
 * @param string  $p_subject   Subject of email message.
 * @param string  $p_message   Body text of email message.
 * @param array   $p_headers   Array of additional headers to send with the email.
 * @param boolean $p_force     True to force sending of emails in shutdown function,
 *                             even when using cronjob
 * @return integer|null
 */
function email_store($p_recipient, $p_subject, $p_message, array $p_headers = null, $p_force = false)
{
    global $g_email_shutdown_processing;
    $t_recipient = trim($p_recipient);
    $t_subject = string_email(trim($p_subject));
    $t_message = string_email_links(trim($p_message));
    # short-circuit if no recipient is defined, or email disabled
    # note that this may cause signup messages not to be sent
    if (is_blank($p_recipient) || OFF == config_get('enable_email_notification')) {
        return null;
    }
    $t_email_data = new EmailData();
    $t_email_data->email = $t_recipient;
    $t_email_data->subject = $t_subject;
    $t_email_data->body = $t_message;
    $t_email_data->metadata = array();
    $t_email_data->metadata['headers'] = $p_headers === null ? array() : $p_headers;
    $t_email_data->metadata['priority'] = config_get('mail_priority');
    # Urgent = 1, Not Urgent = 5, Disable = 0
    $t_email_data->metadata['charset'] = 'utf-8';
    $t_hostname = '';
    if (isset($_SERVER['SERVER_NAME'])) {
        $t_hostname = $_SERVER['SERVER_NAME'];
    } else {
        $t_address = explode('@', config_get('from_email'));
        if (isset($t_address[1])) {
            $t_hostname = $t_address[1];
        }
    }
    $t_email_data->metadata['hostname'] = $t_hostname;
    $t_email_id = email_queue_add($t_email_data);
    # Set the email processing flag for the shutdown function
    $g_email_shutdown_processing |= EMAIL_SHUTDOWN_GENERATED;
    if ($p_force) {
        $g_email_shutdown_processing |= EMAIL_SHUTDOWN_FORCE;
    }
    return $t_email_id;
}
Example #2
0
/**
 * Store email in queue for sending
 *
 * @param string $p_recipient
 * @param string $p_subject
 * @param string $p_message
 * @param array $p_headers
 * @return int e-mail queue id, or NULL if e-mail was not stored
 */
function email_store($p_recipient, $p_subject, $p_message, $p_headers = null)
{
    $t_recipient = trim($p_recipient);
    $t_subject = string_email(trim($p_subject));
    $t_message = string_email_links(trim($p_message));
    # short-circuit if no recipient is defined, or email disabled
    # note that this may cause signup messages not to be sent
    if (is_blank($p_recipient) || OFF == config_get('enable_email_notification')) {
        return;
    }
    $t_email_data = new EmailData();
    $t_email_data->email = $t_recipient;
    $t_email_data->subject = $t_subject;
    $t_email_data->body = $t_message;
    $t_email_data->metadata = array();
    $t_email_data->metadata['headers'] = $p_headers === null ? array() : $p_headers;
    $t_email_data->metadata['priority'] = config_get('mail_priority');
    # Urgent = 1, Not Urgent = 5, Disable = 0
    $t_email_data->metadata['charset'] = 'utf-8';
    $t_hostname = '';
    $t_server = isset($_SERVER) ? $_SERVER : $HTTP_SERVER_VARS;
    if (isset($t_server['SERVER_NAME'])) {
        $t_hostname = $t_server['SERVER_NAME'];
    } else {
        $t_address = explode('@', config_get('from_email'));
        if (isset($t_address[1])) {
            $t_hostname = $t_address[1];
        }
    }
    $t_email_data->metadata['hostname'] = $t_hostname;
    $t_email_id = email_queue_add($t_email_data);
    return $t_email_id;
}
Example #3
0
    if (defined('MANTIS_VERSION')) {
        $t_mantis_version = MANTIS_VERSION;
    } else {
        $t_mantis_version = config_get('mantis_version');
    }
    if (version_compare($t_mantis_version, '1.1.0a2', '>=')) {
        foreach ($t_email_ids as $t_email) {
            $t_recipient = trim($t_email);
            $t_subject = string_email(trim($t_subject));
            $t_message = string_email_links(trim($t_message));
            $t_email_data = new EmailData();
            $t_email_data->email = $t_recipient;
            $t_email_data->subject = $t_subject;
            $t_email_data->body = $t_message;
            $t_email_data->metadata = array();
            $t_email_data->metadata['headers'] = array('X-Mantis' => 'ReleaseMgt');
            $t_email_data->metadata['priority'] = config_get('mail_priority');
            $t_email_data->metadata['charset'] = 'utf-8';
            $t_email_data->metadata['plugins_htmlmail_html_message'] = base64_encode($t_html_message);
            email_queue_add($t_email_data);
        }
        if (OFF == config_get('email_send_using_cronjob')) {
            email_send_all();
        }
    } else {
        foreach ($t_email_ids as $t_email) {
            email_send($t_email, $t_subject, $t_message);
        }
    }
}
release_mgt_successful_redirect($t_redirect_url);