我正在尝试运行此代码:
$this->load->library('email');
$this->email->from('anu1488@gmail.com', 'Anudeep');
$this->email->to('anu1488@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
当我尝试发送时,我收到了这个错误:
A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Filename: libraries/Email.php
Line Number: 1553
是什么造成的?我该如何解决?
答案 0 :(得分:0)
听起来您没有在本地计算机上设置SMTP服务器(邮件服务器)来发送电子邮件。听起来libraries/Email.php
文件正在引用有效邮件服务器不存在的主机名/端口。
答案 1 :(得分:0)
**I guess you need to setup email configuration and port number in config/email .**
$config['protocol']='smtp';
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']='465';
$config['smtp_timeout']='30';
$config['smtp_user']='abhi.abc@gmail.com';
$config['smtp_pass']='password';
$config['charset']='utf-8';
$config['newline']="\r\n";
$config['mailtype'] = "html";
**if every thing is correct from your side then you can just change 'smtp_port' number and then check it definitely it will work`enter code here`.**
答案 2 :(得分:0)
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'user@gmail.com',
'smtp_pass' => 'user password',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('user@gmail.com', 'User');
$this->email->to(sample@gmail.com);
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
if ($this->email->send()) {
$data['error'] = "Your email was sent";
} else {
show_error($this->email->print_debugger());
}
然后打开你的php.ini并转到extension=php_openssl.dll
并取消评论此行。
之后重启你的wamp服务器。