首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >邮件未发送/删除php codeigniter

邮件未发送/删除php codeigniter
EN

Stack Overflow用户
提问于 2017-03-16 20:34:31
回答 2查看 242关注 0票数 1

我正在尝试将忘记密码的链接发送到gmail。但不能获得成功。

这是我的小代码。我这里有我的配置文件。如果需要任何更改,请提出建议。我使用两个gmail帐户从一个gmail帐户向另一个gmail帐户发送邮件。

下面是我的配置文件email.php

代码语言:javascript
运行
复制
<?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']    = 'xyz@gmail.com',
        $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 
    );

这是我的递送邮件代码。

代码语言:javascript
运行
复制
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('xyz@gmail.com', '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');
                }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-16 20:45:13

您的代码中没有任何错误。这可能是因为谷歌的安全问题。登录到您的帐户后,尝试允许访问google帐户设置中的“不太安全的应用程序”

https://www.google.com/settings/security/lesssecureapps

票数 0
EN

Stack Overflow用户

发布于 2017-03-16 20:46:48

管理配置设置,如下所示:

代码语言:javascript
运行
复制
        $config['protocol']    = 'smtp';
        $config['smtp_host']    = 'ssl://smtp.gmail.com';
        $config['smtp_port']    = '465';
        $config['smtp_timeout'] = '7';
        $config['smtp_user']    = 'xyz@gmail.com';
        $config['smtp_pass']    = 'xxxxx';
        $config['charset']    = 'utf-8';
        $config['newline']    = "\r\n";
        $config['mailtype'] = 'text' // or html
        $config['validation'] = TRUE; // bool whether to validate email or not 

然后使用$this->email->initialize($config);加载email库设置配置

代码语言:javascript
运行
复制
$this->load->library('email');
$this->email->initialize($config);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42834261

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档