【问题标题】:Code igniter emailCodeigniter 电子邮件
【发布时间】:2018-08-06 04:50:13
【问题描述】:

您好,我的代码点火器有问题,发送的邮件是我的代码

function __construct()
{
    parent::__construct();
    $this->load->library('email');


}

    function index()
    {
        $this->load->library('email');
        $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'smtp.mailtrap.io',
            'smtp_port' => 2525,
            'smtp_user' => 'edf81f6d31af91',
            'smtp_pass' => '6d824154999158',
            'crlf' => "\r\n",
            'newline' => "\r\n"
        );
        $this->email->initialize($config);

        $this->email->from('b8748b238c-54555a@inbox.mailtrap.io', 'Your Name');
        $this->email->to('dadycool014@hotmail.com');


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

        $this->email->send();



    }

当我执行这段代码时,我得到了这个错误

遇到 PHP 错误 严重性:警告

消息:fsockopen():

文件名:libraries/Email.php

行号:2055

回溯:

文件:C:\xampp\htdocs\ctmprod\application\libraries\Email.php 线路:2055 功能:fsockopen

文件:C:\xampp\htdocs\ctmprod\application\libraries\Email.php 线路:1950 函数:_smtp_connect

文件:C:\xampp\htdocs\ctmprod\application\libraries\Email.php 线路:1825 功能:_send_with_smtp

文件:C:\xampp\htdocs\ctmprod\application\libraries\Email.php 线路:1715 功能:_spool_email

文件:C:\xampp\htdocs\ctmprod\application\controllers\email.php 线路:51 功能:发送

文件:C:\xampp\htdocs\ctmprod\index.php 线路:315 函数:require_once

【问题讨论】:

  • 我希望这些不是您真正的 SMTP 凭据。这真的是警告的全部内容吗?似乎不太可能如此简短。
  • 使用邮件陷阱假 smtp 转储别担心,是的,这就是错误
  • 好的。我希望在Message: fsockopen(): 之后会有更多关于警告的内容?
  • 不,先生,这就是全部信息
  • 从index() 方法中删除$this->load->library('email');。它已经在构造函数中加载了。

标签: php codeigniter codeigniter-2 codeigniter-3


【解决方案1】:
function sesnd_mail()
{
    $this->load->library('email');
    $config = array();
    $config['useragent'] = "CodeIgniter";
    $config['mailpath']  = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
    $config['protocol']  = "smtp";
    $config['smtp_host'] = "smtp.sendgrid.net";
    $config['smtp_user'] = "username";
    $config['smtp_pass'] = "password ";        
    $config['smtp_port'] = "25";
    $config['mailtype']  = 'html';
    $config['charset']   = 'utf-8';
    $config['newline']   = "\r\n";
    $config['wordwrap']  = TRUE;
    $this->load->library('email');
    $this->email->initialize($config);        
    $this->email->subject('TEST SUBJECT');
    $this->email->message("THIS IS A TEST MESSAGE");
    $this->email->from( "yyy@gmail.com"  );        
    $this->email->to("xxx@gmail.com");
    if($this->email->send())
    {
    echo "success";
    }
    else
    {
    echo $this->email->print_debugger();
    }   
}

【讨论】:

  • 我想可能是我的防火墙出了问题,导致它也不起作用
  • 我认为我的代码没问题,这里的问题可能是 Windows Server 2008 上的 Kespersky
猜你喜欢
  • 2016-05-27
  • 2015-10-08
  • 2013-08-02
  • 2017-12-07
  • 2020-07-31
  • 2017-11-28
  • 2011-06-12
  • 2013-01-07
  • 2012-05-04
相关资源
最近更新 更多