我正在尝试将忘记密码的链接发送到 gmail。但无法获得成功。
这是我的小代码。我这里有我的配置文件。如果需要任何更改,请提出建议。我正在使用两个 gmail 帐户将邮件从一个 gmail 帐户发送到另一个 gmail 帐户。
这是我的配置文件email.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config = Array(
$config['protocol'] = 'smtp',
$config['smtp_host'] = 'ssl://smtp.gmail.com',
$config['smtp_port'] = '465',
$config['smtp_timeout'] = '7',
$config['smtp_user'] = '[email protected]',
$config['smtp_pass'] = '123',
$config['charset'] = 'utf-8',
$config['newline'] = "\r\n",
$config['mailtype'] = 'text', // or html
$config['validation'] = TRUE // bool whether to validate email or not
);
这是我发送邮件的代码。
if($this->form_validation->run())
{
//echo 1;
//echo validation_errors();
$this->load->library('email');
$reset_key = md5(uniqid());
$this->load->model('User_Model');
if($this->User_Model->update_reset_key($reset_key))
{
$this->email->from('[email protected]', 'data-+-');
$this->email->to($this->input->post('email'));
$this->email->subject('Reset you account password at Mahesh Makwana');
$message = "<p><h4>You or someone request to reset your password.</h4></p>";
$message.="<a href='".base_url(). "reset_password/".$reset_key."'>Click here to reset your password</a>";
$this->email->message($message);
if($this->email->send())
{
echo 'Kindly check your email '.$this->input->post('email').' to reset your password';
}
else
{
echo 'Cannot send email! Kindly contact to our customer service to help you.!';
}
}
else{
echo 1;
}
}
else
{
//echo 0;
//echo validation_errors();
$this->load->view('include/forgetpassword');
}
你的代码没有错。这可能是因为谷歌安全。登录您的帐户后,尝试在 Google 帐户设置中允许访问“安全性较低的应用程序”
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句