设置fsockopen():发送电子邮件时无法连接到ssl://smtp.gmail.com:465(连接被拒绝)。
My email Controller is:
public function send() {
$from = "abc@gmail.com";
$to = $this->input->post('email');
date_default_timezone_set("Asia/Kolkata");
$ci = get_instance();
$ci->load->library('email');
$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.gmail.com";
$config['smtp_port'] = "465";
$config['smtp_user'] = "abc@gmail.com";
$config['smtp_pass'] = "Mypwd";
$config['mailpath'] = "/usr/sbin/sendmail";
$config['mailtype'] = "text";
$config['newline'] = "'r'n";
$ci->email->initialize($config);
$this->email->from($from, 'Your Name');
$this->email->to($to);
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
//Send mail
if($this->email->send()) {
$this->load->view('pages/successfully'); }
else {
echo "Error in sending Email.";
show_error($this->email->print_debugger());
}
}
遇到PHP错误
严重性:警告
消息:无法修改报头信息-报头已经由(输出开始于/home/simt/public_html/system/core/Exceptions.php:272)
文件名:核心/Common.php
行号:568
回溯:
文件:/home/simt/public_html/应用程序/控制器/Email.php线:46功能:show_error
文件:/home/simt/public_html/index . php线:315功能:require_once
Connection refused表示连接被拒绝。这是因为服务器不期望在端口上连接,或者因为防火墙阻止了连接。在您的情况下,它可能是最后一个,所以检查防火墙,它可能会阻止本地机器上的访问,也会阻止网络中的访问。也可能是服务器前面的防火墙或服务器本身正在阻止访问,例如,如果您的系统在某些已知的发送垃圾邮件的黑名单上。