douxiuyi6529 2015-06-25 06:27
浏览 108
已采纳

已发送邮件但未收到,codeigniter

I have configured the following settings

 $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("
");
$this->email->from('sender-mail@gmail.com', 'Garima');
$this->email->to('receiver-mail@gmail.com');

// mail message here

I get the following message:

Your message has been successfully sent using the following protocol: mail

From: "Garima" send-mail@gmail.com

Return-Path: send-mail@gmail.com

Reply-To: "send-mail@gmail.com"

X-Sender: send-mail@gmail.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <@gmail.com>

Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit

Firstly,If i have defined the protocol as smtp, why does it show the protocol as mail.

Secondly, There is no "to" field in the message shown. Why is it so? what changes do i have to make?

  • 写回答

2条回答 默认 最新

  • dongzhi1904 2015-06-25 06:33
    关注

    You forget to initialize the email config setting in your code

    $this->email->initialize($config);
    

    So your code would be

     $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("
    ");
            $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条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?