【发布时间】:2020-07-25 08:51:13
【问题描述】:
我可以发送邮件,但现在我正在尝试以正确的方式发送邮件,这样看起来很适合recwiver,所以我想附加一个 html 视图文件,因为它看起来也发送了 html 文件,但我不能在其中发送适当的数据,因为它不会动态更改其显示的统计值。
这是我的控制器代码.....
public function forgetuser()
{
$Uid = $this->input->post('uid');
$otp = rand(10,1000000);
$mail = $dat = $this->Lib_model->Select('ur_super_users', '*', array('isActive'=> 1,'id' => $Uid));
$receiverMail = $mail[0]->emailId;
$count = 0 ;
if ($count == 0) {
$f = array(
'otp' => $otp,
);
$this->Lib_model->Update('ur_super_users', $f, array('id' => $Uid));
//$this->Lib_model->Insert('ur_super_users', $f);
//mailer request
$data = Forget_Mail ($receiverMail, $Uid,$otp,$dat);
if (!empty($insert_users)) {
$Msg = array('Msg' => 'Assigned Successfully', 'Type' => 'success');
$this->session->set_flashdata($Msg);
redirect(base_url('/frontend/homepage/forget'));
}
我的邮件助手功能----
if (!function_exists('Forget_Mail')) {
function Forget_Mail($email, $Uid, $otp,$dat)
{
$otp = $otp;
$Uid = $Uid ;
$to_email = $email;
$link = 'http://www.abcd.com/frontend/homepage/forgetpwd/'.$Uid.'/'.$otp.'';
$BaseUrl = '"<?php echo base_url() ?>"';
$from_email = 'info@abcd.com';
$user = array('Uid' => $Uid , 'otp' => $otp);
//$from_name = 'abcd';
$from_name = 'abcd';
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xyz@gmail.com',
'smtp_pass' => 'xyz@1236',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$CI = &get_instance();
$CI->load->library('email', $config);
$CI->email->set_newline("\r\n");
$CI->email->from($from_email, $from_name);
$CI->email->to($to_email); // replace it with receiver mail id
$CI->email->subject('Forget Password Link |' . $from_name); // replace it with relevant subject
//request for html view page to in mail it is loading but not sending varible array value
$body = $CI->load->view('email_templates/forget', $user, TRUE);
$CI->email->message($body);
//Send mail
if ($CI->email->send()){
//prx($link);
redirect(base_url('/frontend/homepage/forget'));
// return true;
} else{return true;
// return false;}
}
}
}
我的视图html文件forget.php
<br>
Click here to Reset Your Password : <b><a href="http://abcd.com/frontend/homepage/forgetpwd/'.$Uid.'/'.$otp.' ">
//this is coming same in received mail not changing with each user
Reset Password</a></b>
<br>
【问题讨论】:
标签: php codeigniter phpmailer codeigniter-3