【问题标题】:Codeigniter 3: Email not sending via third party [duplicate]Codeigniter 3:电子邮件不通过第三方发送[重复]
【发布时间】:2017-11-29 05:10:49
【问题描述】:

我的网站托管在 infinityfree 中,我尝试发送电子邮件但没有收到任何邮件。这是我使用的代码

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'xxx',
    'smtp_pass' => 'xxx',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

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

我是否必须在谷歌或我网站的控制面板中进行设置?谢谢

【问题讨论】:

    标签: php codeigniter email web-hosting


    【解决方案1】:

    这是在 codeigniter 中发送电子邮件的最简单方法

    $this->load->library('email');
    
    $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.');
    
    $this->email->send();
    

    通过使用此代码,您可以检查邮件功能。您还可以关注 codeigniter 电子邮件课程 Codeigniter email class

    【讨论】:

      【解决方案2】:

      试试这个 首先,加载库

      $this->load->library('email');
      
      $this->email->from('test@abc.com', 'Sender Name');
      $this->email->to('to@gmail.com');
      $this->email->subject('Sample');
      $this->email->message('Email testing');
      

      使用条件检查是否发送电子邮件

      if($this->email->send()){
          echo 'Scuuess';
      }else{
          echo 'Fail';
      }
      

      【讨论】:

        猜你喜欢
        • 2018-10-12
        • 1970-01-01
        • 2013-08-06
        • 1970-01-01
        • 1970-01-01
        • 2017-11-30
        • 2012-05-22
        • 2017-07-25
        相关资源
        最近更新 更多