本文整理匯總了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:
示例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;
}
}
}
}
示例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;
}