当前位置: 首页>>代码示例>>PHP>>正文


PHP Mailer::email_format方法代码示例

本文整理汇总了PHP中Mailer::email_format方法的典型用法代码示例。如果您正苦于以下问题:PHP Mailer::email_format方法的具体用法?PHP Mailer::email_format怎么用?PHP Mailer::email_format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mailer的用法示例。


在下文中一共展示了Mailer::email_format方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mactrack_mail

function mactrack_mail($to, $from, $fromname, $subject, $message, $headers = '')
{
    global $config;
    include_once $config['base_path'] . '/plugins/settings/include/mailer.php';
    $subject = trim($subject);
    $message = str_replace('<SUBJECT>', $subject, $message);
    $how = read_config_option('settings_how');
    if ($how < 0 && $how > 2) {
        $how = 0;
    }
    if ($how == 0) {
        $Mailer = new Mailer(array('Type' => 'PHP'));
    } else {
        if ($how == 1) {
            $sendmail = read_config_option('settings_sendmail_path');
            $Mailer = new Mailer(array('Type' => 'DirectInject', 'DirectInject_Path' => $sendmail));
        } else {
            if ($how == 2) {
                $smtp_host = read_config_option('settings_smtp_host');
                $smtp_port = read_config_option('settings_smtp_port');
                $smtp_username = read_config_option('settings_smtp_username');
                $smtp_password = read_config_option('settings_smtp_password');
                $Mailer = new Mailer(array('Type' => 'SMTP', 'SMTP_Host' => $smtp_host, 'SMTP_Port' => $smtp_port, 'SMTP_Username' => $smtp_username, 'SMTP_Password' => $smtp_password));
            }
        }
    }
    if ($from == '') {
        $from = read_config_option('mt_from_email');
        $fromname = read_config_option('mt_from_name');
        if ($from == '') {
            if (isset($_SERVER['HOSTNAME'])) {
                $from = 'Cacti@' . $_SERVER['HOSTNAME'];
            } else {
                $from = 'thewitness@cacti.net';
            }
        }
        if ($fromname == '') {
            $fromname = 'Cacti';
        }
        $from = $Mailer->email_format($fromname, $from);
        if ($Mailer->header_set('From', $from) === false) {
            cacti_log('ERROR: ' . $Mailer->error(), true, "MACTRACK");
            return $Mailer->error();
        }
    } else {
        $from = $Mailer->email_format($fromname, $from);
        if ($Mailer->header_set('From', $from) === false) {
            cacti_log('ERROR: ' . $Mailer->error(), true, "MACTRACK");
            return $Mailer->error();
        }
    }
    if ($to == '') {
        return 'Mailer Error: No <b>TO</b> address set!!<br>If using the <i>Test Mail</i> link, please set the <b>Alert e-mail</b> setting.';
    }
    $to = explode(',', $to);
    foreach ($to as $t) {
        if (trim($t) != '' && !$Mailer->header_set('To', $t)) {
            cacti_log('ERROR: ' . $Mailer->error(), true, "MACTRACK");
            return $Mailer->error();
        }
    }
    $wordwrap = read_config_option('settings_wordwrap');
    if ($wordwrap == '') {
        $wordwrap = 76;
    } else {
        if ($wordwrap > 9999) {
            $wordwrap = 9999;
        } else {
            if ($wordwrap < 0) {
                $wordwrap = 76;
            }
        }
    }
    $Mailer->Config['Mail']['WordWrap'] = $wordwrap;
    if (!$Mailer->header_set('Subject', $subject)) {
        cacti_log('ERROR: ' . $Mailer->error(), true, "MACTRACK");
        return $Mailer->error();
    }
    $text = array('text' => '', 'html' => '');
    $text['html'] = $message . '<br>';
    $text['text'] = strip_tags(str_replace('<br>', "\n", $message));
    $v = mactrack_version();
    $Mailer->header_set('X-Mailer', 'Cacti-MacTrack-v' . $v['version']);
    $Mailer->header_set('User-Agent', 'Cacti-MacTrack-v' . $v['version']);
    if ($Mailer->send($text) == false) {
        cacti_log('ERROR: ' . $Mailer->error(), true, "MACTRACK");
        return $Mailer->error();
    }
    return '';
}
开发者ID:avillaverdec,项目名称:cacti,代码行数:90,代码来源:mactrack_functions.php

示例2: send_mail

function send_mail($to, $from, $subject, $message, $filename = '', $headers = '')
{
    global $config;
    include_once $config["base_path"] . "/plugins/settings/include/mailer.php";
    $message = str_replace('<SUBJECT>', $subject, $message);
    $message = str_replace('<TO>', $to, $message);
    $message = str_replace('<FROM>', $from, $message);
    $how = read_config_option("settings_how");
    if ($how < 0 || $how > 2) {
        $how = 0;
    }
    if ($how == 0) {
        $Mailer = new Mailer(array('Type' => 'PHP'));
    } else {
        if ($how == 1) {
            $sendmail = read_config_option('settings_sendmail_path');
            $Mailer = new Mailer(array('Type' => 'DirectInject', 'DirectInject_Path' => $sendmail));
        } else {
            if ($how == 2) {
                $smtp_host = read_config_option("settings_smtp_host");
                $smtp_port = read_config_option("settings_smtp_port");
                $smtp_username = read_config_option("settings_smtp_username");
                $smtp_password = read_config_option("settings_smtp_password");
                $Mailer = new Mailer(array('Type' => 'SMTP', 'SMTP_Host' => $smtp_host, 'SMTP_Port' => $smtp_port, 'SMTP_Username' => $smtp_username, 'SMTP_Password' => $smtp_password));
            }
        }
    }
    if ($from == '') {
        $from = read_config_option('settings_from_email');
        $fromname = read_config_option('settings_from_name');
        if ($from == "") {
            if (isset($_SERVER['HOSTNAME'])) {
                $from = 'Cacti@' . $_SERVER['HOSTNAME'];
            } else {
                $from = 'Cacti@cactiusers.org';
            }
        }
        if ($fromname == "") {
            $fromname = "Cacti";
        }
        $from = $Mailer->email_format($fromname, $from);
        if ($Mailer->header_set('From', $from) === false) {
            print "ERROR: " . $Mailer->error() . "\n";
            return $Mailer->error();
        }
    } else {
        $from = $Mailer->email_format('Cacti', $from);
        if ($Mailer->header_set('From', $from) === false) {
            print "ERROR: " . $Mailer->error() . "\n";
            return $Mailer->error();
        }
    }
    if ($to == '') {
        return "Mailer Error: No <b>TO</b> address set!!<br>If using the <i>Test Mail</i> link, please set the <b>Alert e-mail</b> setting.";
    }
    $to = explode(',', $to);
    foreach ($to as $t) {
        if (trim($t) != '' && !$Mailer->header_set("To", $t)) {
            print "ERROR: " . $Mailer->error() . "\n";
            return $Mailer->error();
        }
    }
    $wordwrap = read_config_option("settings_wordwrap");
    if ($wordwrap == '') {
        $wordwrap = 76;
    }
    if ($wordwrap > 9999) {
        $wordwrap = 9999;
    }
    if ($wordwrap < 0) {
        $wordwrap = 76;
    }
    $Mailer->Config["Mail"]["WordWrap"] = $wordwrap;
    if (!$Mailer->header_set("Subject", $subject)) {
        print "ERROR: " . $Mailer->error() . "\n";
        return $Mailer->error();
    }
    if (is_array($filename) && !empty($filename) && strstr($message, '<GRAPH>') !== 0) {
        foreach ($filename as $val) {
            $graph_data_array = array("output_flag" => RRDTOOL_OUTPUT_STDOUT);
            $data = @rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array);
            if ($data != "") {
                $cid = $Mailer->content_id();
                if ($Mailer->attach($data, $val['filename'] . '.png', "image/png", "inline", $cid) == false) {
                    print "ERROR: " . $Mailer->error() . "\n";
                    return $Mailer->error();
                }
                $message = str_replace('<GRAPH>', "<br><br><img src='cid:{$cid}'>", $message);
            } else {
                $message = str_replace('<GRAPH>', "<br><img src='" . $val['file'] . "'><br>Could not open!<br>" . $val['file'], $message);
            }
        }
    }
    $text = array('text' => '', 'html' => '');
    if ($filename == '') {
        $message = str_replace('<br>', "\n", $message);
        $message = str_replace('<BR>', "\n", $message);
        $message = str_replace('</BR>', "\n", $message);
        $text['text'] = strip_tags($message);
    } else {
//.........这里部分代码省略.........
开发者ID:teddywen,项目名称:cacti,代码行数:101,代码来源:functions.php

示例3: debug

                 $threshold_exceed[$graph["id"]][$graph_item_id]["value"] = $data["threshold"]["value"];
                 $threshold_exceed[$graph["id"]][$graph_item_id]["end"] = $data["threshold"]["end"];
                 $threshold_exceed[$graph["id"]][$graph_item_id]["value_text"] = $data["value_text"];
                 $threshold_exceed[$graph["id"]][$graph_item_id]["threshold"] = $graph["rate_overage"]["threshold"];
                 $threshold_exceed[$graph["id"]][$graph_item_id]["graph_title"] = $data["graph_title"];
             }
         }
     }
 }
 /* Send email notifications */
 if (sizeof($threshold_exceed) > 0) {
     debug("    Sending notification of overage");
     /* Create email object */
     $obj_mail = new Mailer(array("WordWrap" => "132", "Type" => $mailer_type, "SMTP_Host" => $mailer_smtp_server, "SMTP_Port" => $mailer_smtp_port, "SMTP_Username" => $mailer_smtp_username, "SMTP_Password" => $mailer_smtp_password, "CharSet" => $TargetEncoding));
     /* Set email message properties */
     $obj_mail->header_set("From", $obj_mail->email_format($config_globals["threshold_tracking"]["title"], $config_globals["email"]["return_address"]));
     $obj_mail->header_set("Subject", $config_globals["threshold_tracking"]["subject"] . " - " . date($date_format));
     foreach ($emails as $address) {
         $obj_mail->header_set("To", $address);
     }
     $text_part = "";
     $html_part = "";
     /* Create email content */
     $text_part .= $config_globals["threshold_tracking"]["title"] . "\n\n";
     $text_part .= "The following have exceeded committed rate limits:\n\n";
     $html_part .= "<font size=\"+1\"><b>" . $config_globals["threshold_tracking"]["title"] . "</b></font><br><br>";
     $html_part .= "The following have exceeded committed rate limit:<br><br>";
     foreach ($threshold_exceed as $graph_id => $graph) {
         foreach ($graph as $graph_item_id => $data) {
             $text_part .= "  " . $data["graph_title"] . "\n";
             $text_part .= "    Type: " . $data["type_description"] . "\n";
开发者ID:BagusTesa,项目名称:Cacti-ISP-Billing,代码行数:31,代码来源:isp_billing.php

示例4: thold_mail

function thold_mail($to, $from, $subject, $message, $filename, $headers = '')
{
    global $config;
    thold_debug('Preparing to send email');
    include_once $config['base_path'] . '/plugins/settings/include/mailer.php';
    include_once $config['base_path'] . '/plugins/thold/setup.php';
    $subject = trim($subject);
    $message = str_replace('<SUBJECT>', $subject, $message);
    $how = read_config_option('settings_how');
    if ($how < 0 && $how > 2) {
        $how = 0;
    }
    if ($how == 0) {
        $Mailer = new Mailer(array('Type' => 'PHP'));
    } else {
        if ($how == 1) {
            $sendmail = read_config_option('settings_sendmail_path');
            $Mailer = new Mailer(array('Type' => 'DirectInject', 'DirectInject_Path' => $sendmail));
        } else {
            if ($how == 2) {
                $smtp_host = read_config_option('settings_smtp_host');
                $smtp_port = read_config_option('settings_smtp_port');
                $smtp_username = read_config_option('settings_smtp_username');
                $smtp_password = read_config_option('settings_smtp_password');
                $Mailer = new Mailer(array('Type' => 'SMTP', 'SMTP_Host' => $smtp_host, 'SMTP_Port' => $smtp_port, 'SMTP_Username' => $smtp_username, 'SMTP_Password' => $smtp_password));
            }
        }
    }
    if ($from == '') {
        $from = read_config_option('thold_from_email');
        $fromname = read_config_option('thold_from_name');
        if ($from == '') {
            if (isset($_SERVER['HOSTNAME'])) {
                $from = 'Cacti@' . $_SERVER['HOSTNAME'];
            } else {
                $from = 'Cacti@localhost';
            }
        }
        if ($fromname == '') {
            $fromname = 'Cacti';
        }
        $from = $Mailer->email_format($fromname, $from);
        if ($Mailer->header_set('From', $from) === false) {
            print 'ERROR: ' . $Mailer->error() . "\n";
            return $Mailer->error();
        }
    } else {
        $from = $Mailer->email_format('Cacti', $from);
        if ($Mailer->header_set('From', $from) === false) {
            print 'ERROR: ' . $Mailer->error() . "\n";
            return $Mailer->error();
        }
    }
    if ($to == '') {
        return 'Mailer Error: No <b>TO</b> address set!!<br>If using the <i>Test Mail</i> link, please set the <b>Alert e-mail</b> setting.';
    }
    $to = explode(',', $to);
    foreach ($to as $t) {
        if (trim($t) != '' && !$Mailer->header_set('To', $t)) {
            print 'ERROR: ' . $Mailer->error() . "\n";
            return $Mailer->error();
        }
    }
    $wordwrap = read_config_option('settings_wordwrap');
    if ($wordwrap == '') {
        $wordwrap = 76;
    }
    if ($wordwrap > 9999) {
        $wordwrap = 9999;
    }
    if ($wordwrap < 0) {
        $wordwrap = 76;
    }
    $Mailer->Config['Mail']['WordWrap'] = $wordwrap;
    if (!$Mailer->header_set('Subject', $subject)) {
        print 'ERROR: ' . $Mailer->error() . "\n";
        return $Mailer->error();
    }
    if (is_array($filename) && !empty($filename) && strstr($message, '<GRAPH>') !== 0) {
        foreach ($filename as $val) {
            $graph_data_array = array('output_flag' => RRDTOOL_OUTPUT_STDOUT);
            if (function_exists('imagecreatefrompng') && function_exists('imagejpeg')) {
                $data = @png2jpeg(rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array));
                $ext = 'jpg';
            } else {
                $data = @rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array);
                $ext = 'png';
            }
            if ($data != '') {
                $cid = $Mailer->content_id();
                if ($Mailer->attach($data, $val['filename'] . ".{$ext}", "image/{$ext}", 'inline', $cid) == false) {
                    print 'ERROR: ' . $Mailer->error() . "\n";
                    return $Mailer->error();
                }
                $message = str_replace('<GRAPH>', "<br><br><img src='cid:{$cid}'>", $message);
            } else {
                $message = str_replace('<GRAPH>', "<br><img src='" . $val['file'] . "'><br>Could not open!<br>" . $val['file'], $message);
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:caiorasec,项目名称:thold,代码行数:101,代码来源:thold_functions.php


注:本文中的Mailer::email_format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。