编程语言
首页 > 编程语言> > PHP-Codeigniter本地主机电子邮件未发送

PHP-Codeigniter本地主机电子邮件未发送

作者:互联网

我有问题,我听不懂.
这是我的代码

$this->load->library('email');
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;


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

$this->email->from('rudzstyle@yahoo.co.id', 'Your Name');
$this->email->to('rudzstyle@gmail.com');
$message = $data->nama_depan.'<br>'.$this->input->post('snk');
$this->email->subject($message);
$this->email->message('Testing the email class.');

$this->email->send();

echo $this->email->print_debugger();

这2个电子邮件是有效电子邮件.

调试器的结果是

Exit status code: 1 Unable to open a socket to Sendmail. Please check
settings. Unable to send email using PHP Sendmail. Your server might
not be configured to send mail using this method.

User-Agent: CodeIgniter Date: Mon, 2 Jun 2014 07:53:21 +0200 From:
“Your Name” Return-Path: To: rudzstyle@gmail.com Subject:
=?iso-8859-1?Q?Riyanto test?=
=?iso-8859-1?Q??= Reply-To: “rudzstyle@yahoo.co.id” X-Sender: rudzstyle@yahoo.co.id X-Mailer: CodeIgniter X-Priority: 3
(Normal) Message-ID: <538c1151179cb@yahoo.co.id> Mime-Version: 1.0

Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Testing the email class.

解决方法:

在Codeigniter中,试试这个

$this->load->library('email');
$config['protocol']='smtp';
$config['smtp_host']='your host';
$config['smtp_port']='465';
$config['smtp_timeout']='30';
$config['smtp_user']='your mail id';
$config['smtp_pass']='your password';
$config['charset']='utf-8';
$config['newline']="\r\n";
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from('no-reply@your-site.com', 'Site name');
$this->email->to('to-address-mail-id');
$this->email->subject('Notification Mail');
$this->email->message('Your message');
$this->email->send();

在$config [‘smtp_user’]字段中,提供您的email_id,在$config [‘smtp_pass’]字段中,提供该邮件的密码.

这将起作用.尝试一下.
希望这能解决您的问题.

标签:php,codeigniter,email,gmail,yahoo
来源: https://codeday.me/bug/20191009/1881526.html