首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Rest客户端发送邮件(Codeigniter)

在Rest客户端发送邮件(Codeigniter)
EN

Stack Overflow用户
提问于 2013-10-29 07:50:03
回答 2查看 1K关注 0票数 2

我正在为我的android应用程序开发web服务,我的电子邮件功能很难正常工作。我遵循本教程这里

在我的控制器里我有这样一个:

代码语言:javascript
运行
复制
function forgotPassword_get(){
        $this->load->model('model');
        
        $this->response->format = 'json';
        
        $email = $this->get('email');
    
    $config['protocol'] = 'sendmail';
    $config['mailpath'] = '/usr/sbin/sendmail';
    $config['charset'] = 'iso-8859-1';

    // gmail specific settings here
    $config['smtp_host'] = 'smtp.gmail.com';
    $config['smtp_user'] = 'my email here';
    $config['smtp_pass'] = 'password here';
    $config['smtp_port'] = '465';

    $config['wordwrap'] = TRUE;

    $this->load->library('email');
    $this->email->initialize($config);
    
        $this->email->from('mailfrom', 'sample name');
        $this->email->to('mailto'); 

        $this->email->subject('sample email');
        $this->email->message('sample message for email.'); 

        $this->email->send();

        echo $this->email->print_debugger();
        
    }

结果是

代码语言:javascript
运行
复制
Your message has been successfully sent using the following protocol: sendmail
    User-Agent: CodeIgniter
    Date: Tue, 29 Oct 2013 15:45:57 +0800
    From: "sample name" 
    X-Mailer: CodeIgniter
    X-Priority: 3 (Normal)
    Message-ID: <526f67b5f16b8@mobilemo.com>
    Mime-Version: 1.0
    Content-Type: text/plain; charset=iso-8859-1
    Content-Transfer-Encoding: 8bit

sample message for email.

它说这封邮件发送成功,但我认为邮件没有到达我的收件箱。

有人能帮我吗我想我错过了什么。提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-29 10:47:53

你可能想试试这个:

代码语言:javascript
运行
复制
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'emailhere@gmail.com';
$config['smtp_pass'] = 'password Here';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "\r\n";

$this->load->library('email');
$this->email->initialize($config);

我只是改变了你的配置项目。希望能帮上忙。

票数 2
EN

Stack Overflow用户

发布于 2013-10-29 08:02:42

您是否在Gmail中启用SMTP访问,如果我没记错的话,您必须单击Gmail中的一些复选框,例如“允许第三方使用此帐户发送邮件”。这也不是很好的做法,因为Gmail会不断警告您有人试图访问您的帐户。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19652493

复制
相关文章

相似问题

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