在 Codeigniter 中无法发送电子邮件 - fsockopen(): 无法连接到 ssl://smtp.gmail.com:465(连接被拒绝)
in Codeigniter Unable to send email - fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
设置 fsockopen():发送电子邮件时无法连接到 ssl://smtp.gmail.com:465(连接被拒绝)。
我的电子邮件控制器是:
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());
}
}
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/simt/public_html/system/core/Exceptions.php:272)
Filename: core/Common.php
Line Number: 568
Backtrace:
File: /home/simt/public_html/application/controllers/Email.php
Line: 46
Function: show_error
File: /home/simt/public_html/index.php
Line: 315
Function: require_once
连接被拒绝意味着与对等方的连接被拒绝。这是因为服务器不希望在该端口建立连接,或者因为防火墙阻止了连接。在您的情况下,这可能是最后一个,因此请检查防火墙,它可能会阻止本地计算机以及网络中的访问。也可能是服务器前面的防火墙或服务器本身正在阻止访问,例如,如果您的系统位于某个以发送垃圾邮件而闻名的黑名单上。
设置 fsockopen():发送电子邮件时无法连接到 ssl://smtp.gmail.com:465(连接被拒绝)。
我的电子邮件控制器是:
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());
}
}
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/simt/public_html/system/core/Exceptions.php:272)
Filename: core/Common.php
Line Number: 568
Backtrace:
File: /home/simt/public_html/application/controllers/Email.php Line: 46 Function: show_error
File: /home/simt/public_html/index.php Line: 315 Function: require_once
连接被拒绝意味着与对等方的连接被拒绝。这是因为服务器不希望在该端口建立连接,或者因为防火墙阻止了连接。在您的情况下,这可能是最后一个,因此请检查防火墙,它可能会阻止本地计算机以及网络中的访问。也可能是服务器前面的防火墙或服务器本身正在阻止访问,例如,如果您的系统位于某个以发送垃圾邮件而闻名的黑名单上。