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


PHP Mailer::error方法代码示例

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


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

示例1: getInstance

 /**
  * Configures and fetches a singleton instance of `Zend_Mail`.
  * Also clears settings from previous use onthe `Zend_Mail` object
  * unless you call `getInstance(false)`.
  */
 public static function getInstance($clear = true)
 {
     // Has it been requested before?
     if (self::$mailer === null) {
         // Parse/verify configuration file
         self::$config = conf('Mailer');
         // Create the new Zend_Mail object
         self::$mailer = new Zend_Mail('UTF-8');
         // Set the transport method
         if (!isset(self::$config['transport']) || !isset(self::$config['transport']['type'])) {
             self::$error = 'No transport method defined.';
             return false;
         }
         switch (self::$config['transport']['type']) {
             case 'smtp':
                 $config = self::$config['transport'];
                 $host = $config['host'];
                 unset($config['host']);
                 unset($config['type']);
                 require_once 'Zend/Mail/Transport/Smtp.php';
                 self::$transport = new Zend_Mail_Transport_Smtp($host, $config);
                 break;
             case 'sendmail':
                 require_once 'Zend/Mail/Transport/Sendmail.php';
                 self::$transport = new Zend_Mail_Transport_Sendmail();
                 break;
             case 'file':
                 if (!isset(self::$config['transport']['path'])) {
                     self::$config['transport']['path'] = 'cache/mailer';
                 }
                 if (!file_exists(self::$config['transport']['path'])) {
                     mkdir(self::$config['transport']['path']);
                 }
                 require_once 'Zend/Mail/Transport/File.php';
                 self::$transport = new Zend_Mail_Transport_File(array('path' => self::$config['transport']['path'], 'callback' => function ($transport) {
                     // Files are named DATETIME-RECIPIENT-RAND.tmp
                     return $_SERVER['REQUEST_TIME'] . '-' . $transport->recipients . '-' . mt_rand() . '.tmp';
                 }));
                 break;
             default:
                 self::$error = 'Unknown transport type.';
                 return false;
         }
         Zend_Mail::setDefaultTransport(self::$transport);
         // Set default from info
         $email_from = self::$config['email_from'] !== 'default' ? self::$config['email_from'] : conf('General', 'email_from');
         $email_name = self::$config['email_name'] !== 'default' ? self::$config['email_name'] : conf('General', 'site_name');
         Zend_Mail::setDefaultFrom($email_from, $email_name);
     }
     // Clear mailer settings
     if ($clear) {
         self::$mailer->clearRecipients();
         self::$mailer->clearSubject();
         self::$mailer->clearFrom();
     }
     return self::$mailer;
 }
开发者ID:nathanieltite,项目名称:elefant,代码行数:62,代码来源:Mailer.php

示例2: 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

示例3: 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

示例4: date

         $html_part .= "&nbsp;&nbsp;&nbsp;&nbsp;<b>Type:</b> " . $data["type_description"] . "<br>\n";
         $html_part .= "&nbsp;&nbsp;&nbsp;&nbsp;<b>Committed Rate</b>: " . unit_display($data["threshold"]) . "<br>\n";
         $html_part .= "&nbsp;&nbsp;&nbsp;&nbsp;<b>Occured:</b> " . date($date_format, $data["end"]) . "<br>\n";
         $html_part .= "&nbsp;&nbsp;&nbsp;&nbsp;<b>Value:</b> " . unit_display($data["value"]) . "<br><br>\n";
         if ($data["type"] == "Nth") {
             $text_part .= "  *** If you continue at your current rate of usage, you will exceed your committed rate at time of billing. ***\n\n";
             $html_part .= "&nbsp;&nbsp;<b><i><font color=\"red\">If you continue at your current rate of usage, you will exceed your committed rate at time of billing.</font></i></b>\n\n";
         }
     }
 }
 /* Send email */
 $error = FALSE;
 if ($email["html"] == 1) {
     if ($obj_mail->send(array("text" => $text_part, "html" => $html_part)) === false) {
         print "ERROR: Unable to send mail to: " . $email["address"] . "\n";
         print "ERROR: " . $obj_mail->error() . "\n";
         $error = TRUE;
     }
 } else {
     if ($obj_mail->send($text_part) === false) {
         print "ERROR: Unable to send mail to: " . $email["address"] . "\n";
         print "ERROR: " . $obj_mail->error() . "\n";
         $error = TRUE;
     }
 }
 /* Kill mail object */
 $obj_mail->close();
 $obj_mail = FALSE;
 /* Update notification count in track file */
 if ($error == FALSE) {
     foreach ($threshold_exceed as $graph_id => $graph) {
开发者ID:BagusTesa,项目名称:Cacti-ISP-Billing,代码行数:31,代码来源:isp_billing.php

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