本文整理汇总了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");
}