/**
 * return formatted string with all the details on the requested relationship
 * @param integer             $p_bug_id       A bug identifier.
 * @param BugRelationshipData $p_relationship A bug relationship object.
 * @param boolean             $p_html         Whether to return html or text output.
 * @param boolean             $p_html_preview Whether to include style/hyperlinks - if preview is false, we prettify the output.
 * @param boolean             $p_show_project Show Project details.
 * @return string
 */
function relationship_get_details($p_bug_id, BugRelationshipData $p_relationship, $p_html = false, $p_html_preview = false, $p_show_project = false)
{
    $t_summary_wrap_at = utf8_strlen(config_get('email_separator2')) - 28;
    $t_icon_path = config_get('icon_path');
    if ($p_bug_id == $p_relationship->src_bug_id) {
        # root bug is in the source side, related bug in the destination side
        $t_related_bug_id = $p_relationship->dest_bug_id;
        $t_related_project_name = project_get_name($p_relationship->dest_project_id);
        $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
    } else {
        # root bug is in the dest side, related bug in the source side
        $t_related_bug_id = $p_relationship->src_bug_id;
        $t_related_project_name = project_get_name($p_relationship->src_project_id);
        $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
    }
    # related bug not existing...
    if (!bug_exists($t_related_bug_id)) {
        return '';
    }
    # user can access to the related bug at least as a viewer
    if (!access_has_bug_level(VIEWER, $t_related_bug_id)) {
        return '';
    }
    if ($p_html_preview == false) {
        $t_td = '<td>';
    } else {
        $t_td = '<td class="print">';
    }
    # get the information from the related bug and prepare the link
    $t_bug = bug_get($t_related_bug_id, false);
    $t_status_string = get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
    $t_resolution_string = get_enum_element('resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id);
    $t_relationship_info_html = $t_td . string_no_break($t_relationship_descr) . '&#160;</td>';
    if ($p_html_preview == false) {
        $t_relationship_info_html .= '<td><a href="' . string_get_bug_view_url($t_related_bug_id) . '">' . string_display_line(bug_format_id($t_related_bug_id)) . '</a></td>';
        $t_relationship_info_html .= '<td><span class="issue-status" title="' . string_attribute($t_resolution_string) . '">' . string_display_line($t_status_string) . '</span></td>';
    } else {
        $t_relationship_info_html .= $t_td . string_display_line(bug_format_id($t_related_bug_id)) . '</td>';
        $t_relationship_info_html .= $t_td . string_display_line($t_status_string) . '&#160;</td>';
    }
    $t_relationship_info_text = utf8_str_pad($t_relationship_descr, 20);
    $t_relationship_info_text .= utf8_str_pad(bug_format_id($t_related_bug_id), 8);
    # get the handler name of the related bug
    $t_relationship_info_html .= $t_td;
    if ($t_bug->handler_id > 0) {
        $t_relationship_info_html .= string_no_break(prepare_user_name($t_bug->handler_id));
    }
    $t_relationship_info_html .= '&#160;</td>';
    # add project name
    if ($p_show_project) {
        $t_relationship_info_html .= $t_td . string_display_line($t_related_project_name) . '&#160;</td>';
    }
    # add summary
    if ($p_html == true) {
        $t_relationship_info_html .= $t_td . string_display_line_links($t_bug->summary);
        if (VS_PRIVATE == $t_bug->view_state) {
            $t_relationship_info_html .= sprintf(' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get('private'), lang_get('private'));
        }
    } else {
        if (utf8_strlen($t_bug->summary) <= $t_summary_wrap_at) {
            $t_relationship_info_text .= string_email_links($t_bug->summary);
        } else {
            $t_relationship_info_text .= utf8_substr(string_email_links($t_bug->summary), 0, $t_summary_wrap_at - 3) . '...';
        }
    }
    # add delete link if bug not read only and user has access level
    if (!bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && $p_html_preview == false) {
        if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
            $t_relationship_info_html .= ' [<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id . '&amp;rel_id=' . $p_relationship->id . htmlspecialchars(form_security_param('bug_relationship_delete')) . '">' . lang_get('delete_link') . '</a>]';
        }
    }
    $t_relationship_info_html .= '&#160;</td>';
    $t_relationship_info_text .= "\n";
    if ($p_html_preview == false) {
        # choose color based on status
        $t_status_label = html_get_status_css_class($t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
        $t_relationship_info_html = '<tr class="' . $t_status_label . '">' . $t_relationship_info_html . '</tr>' . "\n";
    } else {
        $t_relationship_info_html = '<tr>' . $t_relationship_info_html . '</tr>';
    }
    if ($p_html == true) {
        return $t_relationship_info_html;
    } else {
        return $t_relationship_info_text;
    }
}
Example #2
0
/**
 * This function sends an email message based on the supplied email data.
 *
 * @param EmailData $p_email_data
 * @return bool
 */
function email_send($p_email_data)
{
    global $g_phpMailer;
    $t_email_data = $p_email_data;
    $t_recipient = trim($t_email_data->email);
    $t_subject = string_email(trim($t_email_data->subject));
    $t_message = string_email_links(trim($t_email_data->body));
    $t_debug_email = config_get('debug_email');
    $t_mailer_method = config_get('phpMailer_method');
    $t_log_msg = 'ERROR: Message could not be sent - ';
    if (is_null($g_phpMailer)) {
        if ($t_mailer_method == PHPMAILER_METHOD_SMTP) {
            register_shutdown_function('email_smtp_close');
        }
        $mail = new PHPMailer(true);
    } else {
        $mail = $g_phpMailer;
    }
    if (isset($t_email_data->metadata['hostname'])) {
        $mail->Hostname = $t_email_data->metadata['hostname'];
    }
    # @@@ should this be the current language (for the recipient) or the default one (for the user running the command) (thraxisp)
    $t_lang = config_get('default_language');
    if ('auto' == $t_lang) {
        $t_lang = config_get('fallback_language');
    }
    $mail->SetLanguage(lang_get('phpmailer_language', $t_lang));
    # Select the method to send mail
    switch (config_get('phpMailer_method')) {
        case PHPMAILER_METHOD_MAIL:
            $mail->IsMail();
            break;
        case PHPMAILER_METHOD_SENDMAIL:
            $mail->IsSendmail();
            break;
        case PHPMAILER_METHOD_SMTP:
            $mail->IsSMTP();
            // SMTP collection is always kept alive
            $mail->SMTPKeepAlive = true;
            if (!is_blank(config_get('smtp_username'))) {
                # Use SMTP Authentication
                $mail->SMTPAuth = true;
                $mail->Username = config_get('smtp_username');
                $mail->Password = config_get('smtp_password');
            }
            if (!is_blank(config_get('smtp_connection_mode'))) {
                $mail->SMTPSecure = config_get('smtp_connection_mode');
            }
            $mail->Port = config_get('smtp_port');
            break;
    }
    $mail->IsHTML(false);
    # set email format to plain text
    $mail->WordWrap = 80;
    # set word wrap to 50 characters
    $mail->Priority = $t_email_data->metadata['priority'];
    # Urgent = 1, Not Urgent = 5, Disable = 0
    $mail->CharSet = $t_email_data->metadata['charset'];
    $mail->Host = config_get('smtp_host');
    $mail->From = config_get('from_email');
    $mail->Sender = config_get('return_path_email');
    $mail->FromName = config_get('from_name');
    $mail->AddCustomHeader('Auto-Submitted:auto-generated');
    $mail->AddCustomHeader('X-Auto-Response-Suppress: All');
    if (OFF !== $t_debug_email) {
        $t_message = 'To: ' . $t_recipient . "\n\n" . $t_message;
        $t_recipient = $t_debug_email;
    }
    try {
        $mail->AddAddress($t_recipient, '');
    } catch (phpmailerException $e) {
        log_event(LOG_EMAIL, $t_log_msg . $mail->ErrorInfo);
        $t_success = false;
        $mail->ClearAllRecipients();
        $mail->ClearAttachments();
        $mail->ClearReplyTos();
        $mail->ClearCustomHeaders();
        return $t_success;
    }
    $mail->Subject = $t_subject;
    $mail->Body = make_lf_crlf("\n" . $t_message);
    if (isset($t_email_data->metadata['headers']) && is_array($t_email_data->metadata['headers'])) {
        foreach ($t_email_data->metadata['headers'] as $t_key => $t_value) {
            switch ($t_key) {
                case 'Message-ID':
                    /* Note: hostname can never be blank here as we set metadata['hostname']
                       in email_store() where mail gets queued. */
                    if (!strchr($t_value, '@') && !is_blank($mail->Hostname)) {
                        $t_value = $t_value . '@' . $mail->Hostname;
                    }
                    $mail->set('MessageID', "<{$t_value}>");
                    break;
                case 'In-Reply-To':
                    $mail->AddCustomHeader("{$t_key}: <{$t_value}@{$mail->Hostname}>");
                    break;
                default:
                    $mail->AddCustomHeader("{$t_key}: {$t_value}");
                    break;
            }
        }
    }
    try {
        $t_success = $mail->Send();
        if ($t_success) {
            $t_success = true;
            if ($t_email_data->email_id > 0) {
                email_queue_delete($t_email_data->email_id);
            }
        } else {
            # We should never get here, as an exception is thrown after failures
            log_event(LOG_EMAIL, $t_log_msg . $mail->ErrorInfo);
            $t_success = false;
        }
    } catch (phpmailerException $e) {
        log_event(LOG_EMAIL, $t_log_msg . $mail->ErrorInfo);
        $t_success = false;
    }
    $mail->ClearAllRecipients();
    $mail->ClearAttachments();
    $mail->ClearReplyTos();
    $mail->ClearCustomHeaders();
    return $t_success;
}
Example #3
0
function email_send($p_from, $p_recipient, $p_subject, $p_message, $p_cc = '', $p_exit_on_error = false, $htmlFormat = false)
{
    global $g_phpMailer_smtp;
    $op = new stdClass();
    $op->status_ok = true;
    $op->msg = 'ok';
    // Check fatal Error
    $smtp_host = config_get('smtp_host');
    if (is_blank($smtp_host)) {
        $op->status_ok = false;
        $op->msg = lang_get('stmp_host_unconfigured');
        return $op;
    }
    $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
    # Visit http://phpmailer.sourceforge.net
    # if you have problems with phpMailer
    $mail = new PHPMailer();
    $mail->PluginDir = PHPMAILER_PATH;
    // 20090201 - franciscom
    // Need to get strings file for php mailer
    // To avoid problems I choose ENglish
    $mail->SetLanguage('en', PHPMAILER_PATH . 'language' . DIRECTORY_SEPARATOR);
    # Select the method to send mail
    switch (config_get('phpMailer_method')) {
        case 0:
            $mail->IsMail();
            break;
        case 1:
            $mail->IsSendmail();
            break;
        case 2:
            $mail->IsSMTP();
            # SMTP collection is always kept alive
            #
            $mail->SMTPKeepAlive = true;
            # @@@ yarick123: It is said in phpMailer comments, that phpMailer::smtp has private access.
            # but there is no common method to reset PHPMailer object, so
            # I see the smallest evel - to initialize only one 'private'
            # field phpMailer::smtp in order to reuse smtp connection.
            if (is_null($g_phpMailer_smtp)) {
                register_shutdown_function('email_smtp_close');
            } else {
                $mail->smtp = $g_phpMailer_smtp;
            }
            break;
    }
    $mail->IsHTML($htmlFormat);
    # set email format to plain text
    $mail->WordWrap = 80;
    $mail->Priority = config_get('mail_priority');
    # Urgent = 1, Not Urgent = 5, Disable = 0
    $mail->CharSet = config_get('charset');
    $mail->Host = config_get('smtp_host');
    $mail->From = config_get('from_email');
    if (!is_blank($p_from)) {
        $mail->From = $p_from;
    }
    $mail->Sender = config_get('return_path_email');
    $mail->FromName = '';
    if (!is_blank(config_get('smtp_username'))) {
        # Use SMTP Authentication
        $mail->SMTPAuth = true;
        $mail->Username = config_get('smtp_username');
        $mail->Password = config_get('smtp_password');
    }
    $t_debug_to = '';
    # add to the Recipient list
    $t_recipient_list = split(',', $t_recipient);
    while (list(, $t_recipient) = each($t_recipient_list)) {
        if (!is_blank($t_recipient)) {
            $mail->AddAddress($t_recipient, '');
        }
    }
    // 20051106 - fm
    $t_cc_list = split(',', $p_cc);
    while (list(, $t_cc) = each($t_cc_list)) {
        if (!is_blank($t_cc)) {
            $mail->AddCC($t_cc, '');
        }
    }
    $mail->Subject = $t_subject;
    $mail->Body = make_lf_crlf("\n" . $t_message);
    if (!$mail->Send()) {
        if ($p_exit_on_error) {
            print "PROBLEMS SENDING MAIL TO: {$p_recipient}<br />";
            print 'Mailer Error: ' . $mail->ErrorInfo . '<br />';
            exit;
        } else {
            $op->status_ok = false;
            $op->msg = $mail->ErrorInfo;
            return $op;
        }
    }
    if (!is_null($mail->smtp)) {
        # @@@ yarick123: It is said in phpMailer comments, that phpMailer::smtp has private access.
        # but there is no common method to reset PHPMailer object, so
        # I see the smallest evel - to initialize only one 'private'
        # field phpMailer::smtp in order to reuse smtp connection.
        $g_phpMailer_smtp = $mail->smtp;
    }
    return $op;
}
function GetRelationshipContent($p_bug_id, $p_html = false, $p_html_preview = false, $p_summary = false, $p_icons = false)
{
    $t_summary = '';
    $t_icons = '';
    $t_show_project = false;
    $t_summary_wrap_at = utf8_strlen(config_get('email_separator2')) - 10;
    $t_relationship_all = relationship_get_all($p_bug_id, $t_show_project);
    $t_relationship_all_count = count($t_relationship_all);
    if ($p_summary) {
        for ($i = 0; $i < $t_relationship_all_count; $i++) {
            $p_relationship = $t_relationship_all[$i];
            if ($p_bug_id == $p_relationship->src_bug_id) {
                # root bug is in the src side, related bug in the dest side
                $t_related_bug_id = $p_relationship->dest_bug_id;
                $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
            } else {
                # root bug is in the dest side, related bug in the src side
                $t_related_bug_id = $p_relationship->src_bug_id;
                $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
            }
            # get the information from the related bug and prepare the link
            $t_bug = bug_get($t_related_bug_id, false);
            $t_text = trim(utf8_str_pad($t_relationship_descr, 20)) . ' ';
            if ($p_html_preview == true) {
                $t_text .= '<a href="' . string_get_bug_view_url($t_related_bug_id) . '"';
                $t_text .= ' class="rcv_tooltip"';
                //$t_text .= ' title="' . utf8_str_pad (bug_format_id ($t_related_bug_id), 8) . "\n" . string_attribute ($t_bug->summary) . '"';
                $t_text .= '>';
            }
            $t_text .= string_display_line(bug_format_id($t_related_bug_id));
            if ($p_html_preview == true) {
                $t_text .= '<span class="rcv_tooltip_box">';
                $t_text .= '<span class="rcv_tooltip_title">' . bug_format_id($t_related_bug_id) . '</span>';
                $t_text .= '<span class="rcv_tooltip_content">' . utf8_substr(string_email_links($t_bug->summary), 0, MAX_TOOLTIP_CONTENT_LENGTH);
                $t_text .= MAX_TOOLTIP_CONTENT_LENGTH < strlen($t_bug->summary) ? '...' : '';
                $t_text .= '</span>';
                $t_text .= '</span>';
                $t_text .= '</a>';
            }
            if (plugin_config_get('ShowRelationshipsControl') && !bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && true == $p_html_preview) {
                // bug not read only
                if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
                    // user has access level
                    // add a delete link
                    $t_text .= ' [';
                    $t_text .= '<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id;
                    $t_text .= '&amp;rel_id=' . $p_relationship->id;
                    $t_text .= '&amp;redirect_url=view_all_bug_page.php';
                    $t_text .= htmlspecialchars(form_security_param('bug_relationship_delete'));
                    $t_text .= '">' . lang_get('delete_link') . '</a>';
                    $t_text .= ']';
                }
            }
            // $t_text = relationship_get_details ($p_bug_id, $t_relationship_all[$i], true, false, $t_show_project);
            if (false == $p_html) {
                // p_html == No
                if ($i != 0) {
                    if ($p_html_preview == true) {
                        $t_summary .= ",<br/>";
                    } else {
                        $t_summary .= ", ";
                    }
                }
                $t_summary .= $t_text;
            } else {
                // p_html == Yes
                if ($p_html_preview == true) {
                    $t_summary .= '<tr bgcolor="' . get_status_color($t_bug->status, auth_get_current_user_id(), $t_bug->project_id) . '">';
                    $t_summary .= '<td>' . $t_text . '</td>';
                    $t_summary .= '</tr>' . "\n";
                } else {
                    if ($i != 0) {
                        $t_summary .= ", ";
                    }
                    $t_summary .= $t_text;
                }
            }
        }
    }
    if (plugin_config_get('ShowRelationshipIcons') && !current_user_is_anonymous() && true == $p_html_preview) {
        $t_text = RelationshipsUtils::GetBugSmybols($p_bug_id, !is_blank($t_summary));
        if (!is_blank($t_text)) {
            if (false == $p_html) {
                // p_html == No
                $t_icons .= $t_text;
            } else {
                // p_html == Yes
                if ($p_html_preview == true) {
                    $t_icons .= '<tr><td>' . $t_text . '</td></tr>' . "\n";
                } else {
                    $t_icons .= $t_text;
                }
            }
        }
    }
    if ($p_html_preview == true) {
        $t_icons_table = '';
        $t_summary_table = '';
        if (!is_blank($t_icons)) {
            $t_icons_table = '<table border="0" width="100%" cellpadding="0" cellspacing="1">' . $t_icons . '</table>';
        }
        if (!is_blank($t_summary)) {
            $t_summary_table = '<table border="0" width="100%" cellpadding="0" cellspacing="1">' . $t_summary . '</table>';
        }
        if (!is_blank($t_icons_table) && !is_blank($t_summary_table)) {
            return '<table border="0" width="100%" cellpadding="0" cellspacing="0">' . '<tr><td valign="top" style="padding:0px;">' . $t_summary_table . '</td><td valign="top" style="padding:0px;">' . $t_icons_table . '</td></tr>' . '</table>';
        } else {
            return $t_summary_table . $t_icons_table;
        }
    } else {
        $t_result = $t_icons;
        if (!is_blank($t_icons) && !is_blank($t_summary)) {
            $t_result .= '<br/>';
        }
        $t_result .= $t_summary;
        return $t_result;
    }
}
/** 
 * sends the actual email 
 * 
 * @param boolean $p_exit_on_error == true - calls exit() on errors, else - returns true 
 * 		on success and false on errors
 * @param boolean $htmlFormat specify text type true = html, false (default) = plain text
 */
function email_send($p_from, $p_recipient, $p_subject, $p_message, $p_cc = '', $p_exit_on_error = false, $htmlFormat = false, $opt = null)
{
    global $g_phpMailer;
    $op = new stdClass();
    $op->status_ok = true;
    $op->msg = 'ok';
    $options = array('strip_email_links' => true);
    $options = array_merge($options, (array) $opt);
    // Check fatal Error
    $smtp_host = config_get('smtp_host');
    if (is_blank($smtp_host)) {
        $op->status_ok = false;
        $op->msg = lang_get('stmp_host_unconfigured');
        return $op;
        // >>>---->
    }
    $t_recipient = trim($p_recipient);
    $t_subject = string_email(trim($p_subject));
    $t_message = trim($p_message);
    $t_message = $options['strip_email_links'] ? string_email_links($p_message) : $p_message;
    # short-circuit if no recipient is defined, or email disabled
    # note that this may cause signup messages not to be sent
    # Visit http://phpmailer.sourceforge.net
    # if you have problems with phpMailer
    $mail = new PHPMailer();
    $mail->PluginDir = PHPMAILER_PATH;
    // Need to get strings file for php mailer
    // To avoid problems I choose ENglish
    $mail->SetLanguage('en', PHPMAILER_PATH . 'language' . DIRECTORY_SEPARATOR);
    # Select the method to send mail
    switch (config_get('phpMailer_method')) {
        case PHPMAILER_METHOD_MAIL:
            $mail->IsMail();
            break;
        case PHPMAILER_METHOD_SENDMAIL:
            $mail->IsSendmail();
            break;
        case PHPMAILER_METHOD_SMTP:
            $mail->IsSMTP();
            # SMTP collection is always kept alive
            $mail->SMTPKeepAlive = true;
            # Copied from last mantis version
            if (!is_blank(config_get('smtp_username'))) {
                # Use SMTP Authentication
                $mail->SMTPAuth = true;
                $mail->Username = config_get('smtp_username');
                $mail->Password = config_get('smtp_password');
            }
            if (!is_blank(config_get('smtp_connection_mode'))) {
                $mail->SMTPSecure = config_get('smtp_connection_mode');
            }
            $mail->Port = config_get('smtp_port');
            // is not a lot clear why this is useful (franciscom)
            // need to use sometime to understand .
            if (is_null($g_phpMailer)) {
                register_shutdown_function('email_smtp_close');
            } else {
                $mail = $g_phpMailer;
            }
            break;
    }
    $mail->IsHTML($htmlFormat);
    # set email format to plain text
    $mail->WordWrap = 80;
    $mail->Priority = config_get('mail_priority');
    # Urgent = 1, Not Urgent = 5, Disable = 0
    $mail->CharSet = config_get('charset');
    $mail->Host = config_get('smtp_host');
    $mail->From = config_get('from_email');
    if (!is_blank($p_from)) {
        $mail->From = $p_from;
    }
    $mail->Sender = config_get('return_path_email');
    $mail->FromName = '';
    $t_debug_to = '';
    # add to the Recipient list
    $t_recipient_list = explode(',', $t_recipient);
    while (list(, $t_recipient) = each($t_recipient_list)) {
        if (!is_blank($t_recipient)) {
            $mail->AddAddress($t_recipient, '');
        }
    }
    $t_cc_list = explode(',', $p_cc);
    while (list(, $t_cc) = each($t_cc_list)) {
        if (!is_blank($t_cc)) {
            $mail->AddCC($t_cc, '');
        }
    }
    $mail->Subject = $t_subject;
    $mail->Body = make_lf_crlf("\n" . $t_message);
    if (!$mail->Send()) {
        if ($p_exit_on_error) {
            print "PROBLEMS SENDING MAIL TO: {$p_recipient}<br />";
            print 'Mailer Error: ' . $mail->ErrorInfo . '<br />';
            exit;
        } else {
            $op->status_ok = false;
            $op->msg = $mail->ErrorInfo;
            return $op;
        }
    }
    return $op;
}
Example #6
0
function email_send($p_email_data)
{
    global $g_phpMailer_smtp;
    $t_email_data = $p_email_data;
    $t_recipient = trim($t_email_data->email);
    $t_subject = string_email(trim($t_email_data->subject));
    $t_message = string_email_links(trim($t_email_data->body));
    $t_debug_email = config_get('debug_email');
    # Visit http://phpmailer.sourceforge.net
    # if you have problems with phpMailer
    $mail = new PHPMailer();
    $mail->PluginDir = PHPMAILER_PATH;
    if (isset($t_email_data->metadata['hostname'])) {
        $mail->Hostname = $t_email_data->metadata['hostname'];
    }
    # @@@ should this be the current language (for the recipient) or the default one (for the user running the command) (thraxisp)
    $t_lang = config_get('default_language');
    if ('auto' == $t_lang) {
        $t_lang = config_get('fallback_language');
    }
    $mail->SetLanguage(lang_get('phpmailer_language', $t_lang), PHPMAILER_PATH . 'language' . DIRECTORY_SEPARATOR);
    # Select the method to send mail
    switch (config_get('phpMailer_method')) {
        case 0:
            $mail->IsMail();
            break;
        case 1:
            $mail->IsSendmail();
            break;
        case 2:
            $mail->IsSMTP();
            # SMTP collection is always kept alive
            #
            $mail->SMTPKeepAlive = true;
            # @@@ yarick123: It is said in phpMailer comments, that phpMailer::smtp has private access.
            # but there is no common method to reset PHPMailer object, so
            # I see the smallest evel - to initialize only one 'private'
            # field phpMailer::smtp in order to reuse smtp connection.
            if (is_null($g_phpMailer_smtp)) {
                register_shutdown_function('email_smtp_close');
            } else {
                $mail->smtp = $g_phpMailer_smtp;
            }
            break;
    }
    $mail->IsHTML(false);
    # set email format to plain text
    $mail->WordWrap = 80;
    # set word wrap to 50 characters
    $mail->Priority = $t_email_data->metadata['priority'];
    # Urgent = 1, Not Urgent = 5, Disable = 0
    $mail->CharSet = $t_email_data->metadata['charset'];
    $mail->Host = config_get('smtp_host');
    $mail->From = config_get('from_email');
    $mail->Sender = escapeshellcmd(config_get('return_path_email'));
    $mail->FromName = config_get('from_name');
    if (!is_blank(config_get('smtp_username'))) {
        # Use SMTP Authentication
        $mail->SMTPAuth = true;
        $mail->Username = config_get('smtp_username');
        $mail->Password = config_get('smtp_password');
    }
    if (OFF !== $t_debug_email) {
        $t_message = 'To: ' . $t_recipient . "\n\n" . $t_message;
        $mail->AddAddress($t_debug_email, '');
    } else {
        $mail->AddAddress($t_recipient, '');
    }
    $mail->Subject = $t_subject;
    $mail->Body = make_lf_crlf("\n" . $t_message);
    if (isset($t_email_data->metadata['headers']) && is_array($t_email_data->metadata['headers'])) {
        foreach ($t_email_data->metadata['headers'] as $t_key => $t_value) {
            $mail->AddCustomHeader("{$t_key}: {$t_value}");
        }
    }
    if (!$mail->Send()) {
        $t_success = false;
    } else {
        $t_success = true;
        if ($t_email_data->email_id > 0) {
            email_queue_delete($t_email_data->email_id);
        }
    }
    if (!is_null($mail->smtp)) {
        # @@@ yarick123: It is said in phpMailer comments, that phpMailer::smtp has private access.
        # but there is no common method to reset PHPMailer object, so
        # I see the smallest evel - to initialize only one 'private'
        # field phpMailer::smtp in order to reuse smtp connection.
        $g_phpMailer_smtp = $mail->smtp;
    }
    return $t_success;
}
 /**
  * Prints description how to define and seperate workpackages / chapters
  */
 public function print_workpackage_description_field()
 {
     echo '<span class="small">' . plugin_lang_get('bug_view_work_package_description') . '</span>';
     echo '<a class="rcv_tooltip">';
     echo '&nbsp[i]';
     echo '<span>';
     echo '<div class="rcv_tooltip_content">';
     echo utf8_substr(string_email_links(plugin_lang_get('bug_view_work_package_description_detailed')), 0, 255);
     echo '</div>';
     echo '</span>';
     echo '</a>';
 }
Example #8
0
 foreach ($t_emails as $t_email) {
     if (trim($t_email) != '') {
         $t_id_list[] = trim($t_email);
     }
 }
 $t_email_ids = array_unique($t_id_list);
 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 {
/**
 * @param $lang_string
 * @param $content
 * @param $plugin_lang_flag
 */
function print_story_card_info($lang_string, $content, $plugin_lang_flag)
{
    echo '<div class="rcv_tooltip_content">';
    if ($plugin_lang_flag) {
        echo plugin_lang_get($lang_string);
    } else {
        echo lang_get($lang_string);
    }
    echo ': ' . utf8_substr(string_email_links($content), 0, PLUGINS_STORYBOARD_MAX_TOOLTIP_CONTENT_LENGTH);
    echo PLUGINS_STORYBOARD_MAX_TOOLTIP_CONTENT_LENGTH < strlen($content) ? '...' : '';
    echo '</div>';
}
Example #10
0
function email_send($p_recipient, $p_subject, $p_message, $p_header = '', $p_category = '', $p_exit_on_error = true)
{
    global $g_phpMailer_smtp;
    $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;
    }
    # for debugging only
    #PRINT $t_recipient.'<br />'.$t_subject.'<br />'.$t_message.'<br />'.$t_headers;
    #exit;
    #PRINT '<br />xxxRecipient ='.$t_recipient.'<br />';
    #PRINT 'Headers ='.nl2br($t_headers).'<br />';
    #PRINT $t_subject.'<br />';
    #PRINT nl2br($t_message).'<br />';
    #exit;
    $t_debug_email = config_get('debug_email');
    # Visit http://phpmailer.sourceforge.net
    # if you have problems with phpMailer
    $mail = new PHPMailer();
    $mail->PluginDir = PHPMAILER_PATH;
    # @@@ should this be the current language (for the recipient) or the default one (for the user running the command) (thraxisp)
    $mail->SetLanguage(lang_get('phpmailer_language', lang_get_current()), PHPMAILER_PATH . 'language' . DIRECTORY_SEPARATOR);
    # Select the method to send mail
    switch (config_get('phpMailer_method')) {
        case 0:
            $mail->IsMail();
            break;
        case 1:
            $mail->IsSendmail();
            break;
        case 2:
            $mail->IsSMTP();
            # SMTP collection is always kept alive
            #
            $mail->SMTPKeepAlive = true;
            # @@@ yarick123: It is said in phpMailer comments, that phpMailer::smtp has private access.
            # but there is no common method to reset PHPMailer object, so
            # I see the smallest evel - to initialize only one 'private'
            # field phpMailer::smtp in order to reuse smtp connection.
            if (is_null($g_phpMailer_smtp)) {
                register_shutdown_function('email_smtp_close');
            } else {
                $mail->smtp = $g_phpMailer_smtp;
            }
            break;
    }
    $mail->IsHTML(false);
    # set email format to plain text
    $mail->WordWrap = 80;
    # set word wrap to 50 characters
    $mail->Priority = config_get('mail_priority');
    # Urgent = 1, Not Urgent = 5, Disable = 0
    $mail->CharSet = lang_get('charset', lang_get_current());
    $mail->Host = config_get('smtp_host');
    $mail->From = config_get('from_email');
    $mail->Sender = config_get('return_path_email');
    $mail->FromName = '';
    if (!is_blank(config_get('smtp_username'))) {
        # Use SMTP Authentication
        $mail->SMTPAuth = true;
        $mail->Username = config_get('smtp_username');
        $mail->Password = config_get('smtp_password');
    }
    $t_debug_to = '';
    # add to the Recipient list
    $t_recipient_list = split(',', $t_recipient);
    while (list(, $t_recipient) = each($t_recipient_list)) {
        if (!is_blank($t_recipient)) {
            if (OFF === $t_debug_email) {
                $mail->AddAddress($t_recipient, '');
            } else {
                $t_debug_to .= !is_blank($t_debug_to) ? ', ' : '';
                $t_debug_to .= $t_recipient;
            }
        }
    }
    # add to the BCC list
    $t_debug_bcc = '';
    $t_bcc_list = split(',', $p_header);
    while (list(, $t_bcc) = each($t_bcc_list)) {
        if (!is_blank($t_bcc)) {
            if (OFF === $t_debug_email) {
                $mail->AddBCC($t_bcc, '');
            } else {
                $t_debug_bcc .= !is_blank($t_debug_bcc) ? ', ' : '';
                $t_debug_bcc .= $t_bcc;
            }
        }
    }
    if (OFF !== $t_debug_email) {
        $t_message = "\n" . $t_message;
        if (!is_blank($t_debug_bcc)) {
            $t_message = 'Bcc: ' . $t_debug_bcc . "\n" . $t_message;
        }
        if (!is_blank($t_debug_to)) {
            $t_message = 'To: ' . $t_debug_to . "\n" . $t_message;
        }
        $mail->AddAddress($t_debug_email, '');
    }
    $mail->Subject = $t_subject;
    $mail->Body = make_lf_crlf("\n" . $t_message);
    if (EMAIL_CATEGORY_PROJECT_CATEGORY == config_get('email_set_category')) {
        $mail->AddCustomHeader("Keywords: {$p_category}");
    }
    if (!$mail->Send()) {
        print "PROBLEMS SENDING MAIL TO: {$p_recipient}<br />";
        print 'Mailer Error: ' . $mail->ErrorInfo . '<br />';
        if ($p_exit_on_error) {
            exit;
        } else {
            return false;
        }
    }
    if (!is_null($mail->smtp)) {
        # @@@ yarick123: It is said in phpMailer comments, that phpMailer::smtp has private access.
        # but there is no common method to reset PHPMailer object, so
        # I see the smallest evel - to initialize only one 'private'
        # field phpMailer::smtp in order to reuse smtp connection.
        $g_phpMailer_smtp = $mail->smtp;
    }
    return true;
}