首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >发送但未收到的邮件,代码点火器

发送但未收到的邮件,代码点火器
EN

Stack Overflow用户
提问于 2015-06-25 06:27:07
回答 2查看 9.4K关注 0票数 2

我已经配置了以下设置

代码语言:javascript
运行
复制
 $config = Array(

        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => 'send-mail@gmail.com', // change it to yours
        'smtp_pass' => 'xyz', // change it to yours
        'smtp_timeout'=>20,
        'mailtype' => 'text',
        'charset' => 'iso-8859-1',
        'wordwrap' => TRUE
       );

$this->load->library('email',$config);
//$this->email->set_newline("\r\n");
$this->email->from('sender-mail@gmail.com', 'Garima');
$this->email->to('receiver-mail@gmail.com');

// mail message here

我收到以下信息:

您的邮件已使用以下协议成功发送: 出发地:"Garima“电子邮件@gmail.com 返回路径:发送邮件@gmail.com 回复:“发送邮件@gmail.com” 发件人:电子邮件@gmail.com 邮递员: CodeIgniter X-优先次序:3(正常) 消息-ID:<@gmail.com> Mime-版本: 1.0内容-类型:文本/纯文本;charset=utf-8内容-传输-编码:8位

首先,如果我将协议定义为smtp,为什么它会将协议显示为邮件。

其次,在显示的消息中没有"to“字段。为什么会这样呢?我要做什么改变?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-06-25 06:33:09

您忘记在代码中初始化电子邮件配置设置。

代码语言:javascript
运行
复制
$this->email->initialize($config);

所以你的代码是

代码语言:javascript
运行
复制
 $this->load->library('email');
        $config = Array(
                'protocol' => 'smtp',
                'smtp_host' => 'ssl://smtp.gmail.com',
                'smtp_port' => 465,
                'smtp_user' => 'send-mail@gmail.com', // change it to yours
                'smtp_pass' => 'xyz', // change it to yours
                'smtp_timeout'=>20,
                'mailtype' => 'text',
                'charset' => 'iso-8859-1',
                'wordwrap' => TRUE
               );

         $this->email->initialize($config);// add this line

        //$this->email->set_newline("\r\n");
        $this->email->from('sender-mail@gmail.com', 'Garima');
        $this->email->to('receiver-mail@gmail.com');
        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');  
        $this->email->send();
        echo $this->email->print_debugger();
票数 1
EN

Stack Overflow用户

发布于 2015-06-25 06:46:29

别忘了先加载库

代码语言:javascript
运行
复制
$this->load->library('email');

然后配置这些设置也可以在这里参考

代码语言:javascript
运行
复制
$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'xxx',//your E-mail
    'smtp_pass' => 'xxx',//Your password
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);

$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com'); 
$this->email->cc('another@another-example.com'); 
$this->email->bcc('them@their-example.com'); 

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');  

$result = $this->email->send();

使用本地主机发送邮件

  1. 如果您使用的是XAMPP,请执行此设置用XAMPP发送邮件的堆栈应答
  2. 如果您使用wamp 用WAMP发送邮件的堆栈应答发送邮件

阅读有关CI电子邮件CI电子邮件库的更多信息

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

https://stackoverflow.com/questions/31042758

复制
相关文章

相似问题

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