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


PHP Import::error方法代码示例

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


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

示例1: isset

<?php

require_once "load.php";
$basic = Import::basic();
$data['name'] = '熊永金';
$data['email'] = isset($_POST['useremail']) ? trim($_POST['useremail']) : "";
$data['subject'] = '电子邮箱标题';
$data['content'] = '电子邮箱发布的内容';
$data['type'] = 1;
$data['notification'] = false;
if (isset($_POST['subemail'])) {
    if ($basic->ecshop_sendemail($data)) {
        echo "发送成功!";
    } else {
        $rt = Import::error()->get_all();
        print_r($rt);
        echo "发送失败!";
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>email 发送</title>
</head>

<body>
  <form name="form1" method="post" action="">
  <p>发送EMAIL    </p>
  <p>对方EMAIL:
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:31,代码来源:test_email.php

示例2: ecshop_sendemail

 function ecshop_sendemail($data = array())
 {
     $name = $data['name'];
     $email = $data['email'];
     $subject = $data['subject'];
     $content = $data['content'];
     $type = $data['type'];
     $notification = $data['notification'];
     $charset = "utf-8";
     /**
      * 使用mail函数发送邮件
      */
     if ($GLOBALS['LANG']['mail_service'] == 0 && function_exists('mail')) {
         /* 邮件的头部信息 */
         $content_type = $type == 0 ? 'Content-Type: text/plain; charset=' . $charset : 'Content-Type: text/html; charset=' . $charset;
         $headers = array();
         $headers[] = 'From: "' . '=?' . $charset . '?B?' . base64_encode($GLOBALS['LANG']['site_name']) . '?=' . '" <' . $GLOBALS['LANG']['smtp_mail'] . '>';
         $headers[] = $content_type . '; format=flowed';
         if ($notification) {
             $headers[] = 'Disposition-Notification-To: ' . '=?' . $charset . '?B?' . base64_encode($GLOBALS['LANG']['site_name']) . '?=' . '" <' . $GLOBALS['LANG']['smtp_mail'] . '>';
         }
         $res = @mail($email, '=?' . $charset . '?B?' . base64_encode($subject) . '?=', $content, implode("\r\n", $headers));
         if (!$res) {
             Import::error()->add("邮件发送失败");
             return false;
         } else {
             return true;
         }
     } else {
         /* 邮件的头部信息 */
         $content_type = $type == 0 ? 'Content-Type: text/plain; charset=' . $charset : 'Content-Type: text/html; charset=' . $charset;
         $content = base64_encode($content);
         $headers = array();
         $headers[] = 'Date: ' . gmdate('D, j M Y H:i:s') . ' +0000';
         $headers[] = 'To: "' . '=?' . $charset . '?B?' . base64_encode($name) . '?=' . '" <' . $email . '>';
         $headers[] = 'From: "' . '=?' . $charset . '?B?' . base64_encode($GLOBALS['LANG']['site_name']) . '?=' . '" <' . $GLOBALS['LANG']['smtp_mail'] . '>';
         $headers[] = 'Subject: ' . '=?' . $charset . '?B?' . base64_encode($subject) . '?=';
         $headers[] = $content_type . '; format=flowed';
         $headers[] = 'Content-Transfer-Encoding: base64';
         $headers[] = 'Content-Disposition: inline';
         if ($notification) {
             $headers[] = 'Disposition-Notification-To: ' . '=?' . $charset . '?B?' . base64_encode($GLOBALS['LANG']['shop_name']) . '?=' . '" <' . $GLOBALS['LANG']['smtp_mail'] . '>';
         }
         /* 获得邮件服务器的参数设置 */
         $params['host'] = $GLOBALS['LANG']['smtp_host'];
         $params['port'] = $GLOBALS['LANG']['smtp_port'];
         $params['user'] = $GLOBALS['LANG']['smtp_user'];
         $params['pass'] = $GLOBALS['LANG']['smtp_pass'];
         if (empty($params['host']) || empty($params['port'])) {
             // 如果没有设置主机和端口直接返回 false
             Import::error()->add("邮件服务器的参数设置错误!");
             return false;
         } else {
             // 发送邮件
             if (!function_exists('fsockopen')) {
                 //如果fsockopen被禁用,直接返回
                 Import::error()->add("fsockopen被禁用");
                 return false;
             }
             $send_params['recipients'] = $email;
             $send_params['headers'] = $headers;
             $send_params['from'] = $GLOBALS['LANG']['smtp_mail'];
             $send_params['body'] = $content;
             $smtp = Import::ecshop_smtp($params);
             if (!isset($smtp)) {
                 include_once SYS_PATH . 'lib/class/cls_smtp.php';
                 $smtp = new Ecshop_smtp($params);
             }
             if ($smtp->connect() && $smtp->send($send_params)) {
                 return true;
             } else {
                 $err_msg = $smtp->error_msg();
                 if (empty($err_msg)) {
                     Import::error()->add('Unknown Error');
                 } else {
                     if (strpos($err_msg, 'Failed to connect to server') !== false) {
                         Import::error()->add("SMTP连接失败-" . $params['host'] . ':' . $params['port']);
                     } else {
                         if (strpos($err_msg, 'AUTH command failed') !== false) {
                             Import::error()->add("SMTP登录失败");
                         } elseif (strpos($err_msg, 'bad sequence of commands') !== false) {
                             Import::error()->add("SMTP拒绝错误");
                         } else {
                             print_r($err_msg);
                             echo "run..........";
                             Import::error()->add($err_msg);
                         }
                     }
                 }
                 return false;
             }
         }
     }
 }
开发者ID:jasonhzy,项目名称:fx_demo,代码行数:94,代码来源:basic.php

示例3: send_test

 function send_test($datas = array())
 {
     $basic = Import::basic();
     $data['name'] = '收件人姓名';
     $data['email'] = isset($datas['useremail']) ? trim($datas['useremail']) : "";
     $data['subject'] = '测试标题';
     $data['content'] = '你好,这是一封测试邮件,看到此内容时,表示测试成功!';
     $data['type'] = 1;
     $data['notification'] = false;
     if ($basic->ecshop_sendemail($data)) {
         echo "已测试成功!请稍后查看邮件!";
     } else {
         $rt = Import::error()->get_all();
         print_r($rt);
         echo "发送失败!";
     }
     exit;
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:18,代码来源:controller.php


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