Codeigniter配置:
$config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'shahrushabh1996@gmail.com';
$config['smtp_pass'] = '####';
$config['smtp_port'] = 465;
Codeigniter控制器:
$this->load->library('email');
$this->email->from('shahrushabh1996@gmail.com', 'Webers Infotech');
$this->email->to('shahrushabh1996@gmail.com','Rushabh Shah');
$this->email->subject('Your Subject');
$this->email->message('Your Message');
if (!$this->email->send()) {
show_error($this->email->print_debugger());
}
任何人都可以告诉我如何解决这个问题?为什么不起作用?
答案 0 :(得分:0)
您可以使用以下代码进行检查:
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.app.com'; // if via gmail 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'email@dmail.com';
$config['smtp_pass'] = 'smtp password';
$config['smtp_port'] = port number;
$config['starttls'] = TRUE;
$this->email->initialize($config);
$this->email->from('youremail@domain.com');
$this->email->to('to@domain.com');
$this->email->subject('testing');
$this->email->message('Message content');
if($this->email->send()) {
echo 'Message has been sent';
} else {
$this->email->print_debugger();
}
同时检查php_smtp.dll
。这是否可用。
检查您是否可以使用
<?php
phpinfo();
?>
如果没有找到,请检查php.ini
文件,并且应该有一行
;extension=php_extname.dll
只需删除;从这一行重启php服务(重启Apache)。