本文整理匯總了PHP中mail::send_mail方法的典型用法代碼示例。如果您正苦於以下問題:PHP mail::send_mail方法的具體用法?PHP mail::send_mail怎麽用?PHP mail::send_mail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mail
的用法示例。
在下文中一共展示了mail::send_mail方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: do_edit
/**
* 回複留言信息
*/
function do_edit($id)
{
//權限檢查 得到所有可管理站點ID列表
role::check('contact_us_manage');
if (!$id) {
remind::set(Kohana::lang('o_global.bad_request'), 'user/contact_us');
}
if ($_POST) {
//獲取留言信息,發郵件
$contact_us = Mycontact_us::instance($id)->get();
$email_flag = 'contact_us';
$title_param = array();
$content_param = array();
$content_param['{message}'] = strip_tags($_POST['return_message']);
if (mail::send_mail($email_flag, $contact_us['email'], $from_email = '', $title_param, $content_param)) {
$is_receive = 1;
remind::set(Kohana::lang('o_global.mail_send_success'), '', 'success');
} else {
$is_receive = 0;
remind::set(Kohana::lang('o_global.mail_send_error'), '', 'error');
}
$data = $_POST;
$data['active'] = 0;
$data['is_receive'] = $is_receive;
if (Mycontact_us::instance($id)->edit($data)) {
remind::set(Kohana::lang('o_user.message_handle_success'), request::referrer(), 'success');
} else {
remind::set(Kohana::lang('o_user.message_handle_error'), request::referrer(), 'error');
}
}
}
示例2: do_edit
public function do_edit()
{
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
try {
//* 初始化返回數據 */
$return_data = array();
$request_data = $this->input->post();
/* 數據驗證 ==根據業務邏輯定製== */
if (empty($request_data['id'])) {
throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 403);
}
$validResult = Validation::factory($request_data)->pre_filter('trim')->add_rules('id', 'required', 'digit')->add_rules('is_receive', 'digit')->add_rules('is_show', 'digit')->add_rules('reply_content', 'length[0,1024]');
if (!$validResult->validate()) {
throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 403);
}
//* 邏輯驗證 ==根據業務邏輯定製== */
// 調用底層服務
$productinquiry_service = ProductinquiryService::get_instance();
//* 調用後端服務獲取數據 */
try {
$productinquiry = $productinquiry_service->get($request_data['id']);
if (!isset($productinquiry) || empty($productinquiry)) {
throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
}
$set_data = array('reply_content' => $request_data['reply_content'], 'is_show' => $request_data['is_show'], 'update_timestamp' => date('Y-m-d H:i:s'), 'status' => 1);
if (!empty($request_data['is_receive']) && $productinquiry['is_receive'] != 1) {
$product = ProductService::get_instance()->get($productinquiry['product_id']);
if (!empty($productinquiry['user_id'])) {
$email = Myuser::instance($productinquiry['user_id'])->get('email');
} else {
$email = $productinquiry['email'];
}
$email_flag = 'reply_inquiry';
$title_param = array();
$title_param['{title}'] = strip_tags($product['title']);
$content_param = array();
$content_param['{user_name}'] = strip_tags($productinquiry['user_name']);
$content_param['{reply_content}'] = strip_tags($request_data['reply_content']);
$content_param['{product_title}'] = strip_tags($product['title']);
if (!mail::send_mail($email_flag, $email, '', $title_param, $content_param)) {
throw new MyRuntimeException(Kohana::lang('o_global.mail_send_error'), 500);
} else {
$set_data['is_receive'] = 1;
}
//不套用郵件模板的方式
/*
$subject = 'Reply to Inquiry About '.$product['title'];
$content = '';
$content .= 'Dear '.$productinquiry['user_name'].' :<br>';
$content .= 'Having received your letter regarding the inquiry about '.$product['title'].'.<br>';
$content .= $productinquiry['reply_content'].'<br>';
$content .= 'If we may be of further service, please feel free to contact us.<br>';
$content .= 'Sincerely yours,<br>';
$content .= $site['name'];
if(!mail::send($email,$subject,$content))
{
throw new MyRuntimeException(Kohana::lang('o_global.mail_send_error'), 500);
}
else
{
$set_data['is_receive'] = 1;
}
*/
}
$productinquiry_service->set($productinquiry['id'], $set_data);
} catch (MyRuntimeException $ex) {
throw $ex;
}
//* 補充&修改返回結構體 */
$return_struct['status'] = 1;
$return_struct['code'] = 200;
$return_struct['msg'] = '操作成功';
$return_struct['content'] = $return_data;
$return_struct['action'] = array('type' => 'location', 'url' => url::base() . 'product/' . $this->class_name . '/' . 'index');
//* 請求類型 */
if ($this->is_ajax_request()) {
$this->template->content = $return_struct;
} else {
// html 輸出
$this->template->return_struct = $return_struct;
$content = new View('info');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->request_data = $request_data;
//* 返回結構體綁定 */
$this->template->content->return_struct = $return_struct;
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$return_struct['status'] = 0;
$return_struct['code'] = $ex->getCode();
$return_struct['msg'] = $ex->getMessage();
//TODO 異常處理
//throw $ex;
if ($this->is_ajax_request()) {
$this->template->content = $return_struct;
} else {
$this->template->return_struct = $return_struct;
$content = new View('info');
//.........這裏部分代碼省略.........
示例3: add
/**
* 添加新用戶
*/
function add()
{
//權限檢查 得到所有可管理站點ID列表
role::check('user_add');
$submit_target = intval($this->input->post('submit_target'));
if ($_POST) {
$data = $_POST;
//標簽過濾
tool::filter_strip_tags($data);
$data['password'] = sha1($_POST['password']);
$data['ip'] = tool::get_long_ip();
$data['active'] = 1;
//默認未激活狀態
$data['register_mail_active'] = 1;
$user = Myuser::instance();
if ($user->user_exist($data)) {
remind::set(Kohana::lang('o_user.user_email_has_exist'), request::referrer(), 'error');
}
if ($user->add($data)) {
//發郵件
if ($this->input->post('send_mail') == 1) {
$email_flag = 'reg';
$title_param = array();
$content_param = array();
$content_param['{firstname}'] = $this->input->post('firstname');
$content_param['{password}'] = $this->input->post('password');
$content_param['{email}'] = $this->input->post('email');
if (mail::send_mail($email_flag, $this->input->post('email'), $from_email = '', $title_param, $content_param)) {
//判斷添加成功去向
switch ($submit_target) {
case 1:
remind::set(Kohana::lang('o_global.add_success'), 'user/user/add', 'success');
default:
remind::set(Kohana::lang('o_global.add_success'), 'user/user', 'success');
}
} else {
remind::set(Kohana::lang('o_global.mail_send_error'), '', 'error');
}
}
//判斷添加成功去向
switch ($submit_target) {
case 1:
remind::set(Kohana::lang('o_global.add_success'), 'user/user/add', 'success');
default:
remind::set(Kohana::lang('o_global.add_success'), 'user/user', 'success');
}
} else {
$errors = $user->error();
remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
}
}
$this->template->content = new View("user/user_add");
}