Codeigniter 3:电子邮件不通过第三方发送

时间:2017-11-29 05:10:50

标签: php codeigniter email web-hosting

我的网站是在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();

我是否必须在谷歌或我网站的控制面板中设置某些内容?谢谢

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

试试这个 首先,加载库

$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';
}
相关问题