我在CentOS 6服务器上安装了sendmail,看起来效果很好,因为我可以使用CLI发送测试消息。
但是,当尝试使用CodeIgniter的电子邮件类发送测试邮件时,似乎存在一些问题。我的email.php配置是
$config['protocol'] = 'sendmail';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
用于测试电子邮件的控制器:
$this->load->library('email');
$this->email->from('your@example.com', 'from name');
$this->email->to('someone@somewhere.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
当我通过CodeIgniter发送测试消息时,我收到此错误消息
Exit status code: 71
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.
在配置中切换到SMTP或邮件时,我仍然会收到错误。
有什么建议从哪里开始尝试解决此问题?
答案 0 :(得分:0)
我没有看到您正在初始化邮件配置。 尝试添加$ this-> email-> initialize($ config);
答案 1 :(得分:0)
尝试类似这样的事情
Player
答案 2 :(得分:0)
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '******@gmail.com',
'smtp_pass' => '**********',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
//send email with #temp_pass as a link
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('**********@gmail.com', "Title");
$this->email->to($email);
$this->email->subject("Added");
$message = "<p>This email has been sent as a request to added</p>";
$this->email->message($message);
$this->email->send();
答案 3 :(得分:0)
试试这些。
确保将apache添加到smmsp组。
id apache
如果注释添加到组
usermod -g smmsp apache
chmod -v 2755 /usr/sbin/sendmail.sendmail
将配置[&#39; mailpath&#39;]更改为/use/sbin/sendmail.sendmail
如果这些tweek不起作用,