[英]Codeigniter Email did not Working in Server fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection refused)
Please help me in codeigniter Email, I had many tries but it did not work, Its working On localhost but did not work on server. 请在codeigniter电子邮件中帮助我,我做了很多尝试,但是没有用,它可以在localhost上工作,但是不能在服务器上工作。
ERROR: 错误:
A PHP Error was encountered
遇到PHP错误
Severity: Warning
严重程度:警告
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection refused)
讯息:fsockopen():无法连接至ssl://smtp.googlemail.com:465(拒绝连接)
Filename: libraries/Email.php
文件名:libraries / Email.php
Line Number: 2069
行号:2069
Backtrace:
回溯:
File: /home/b4ger7ik8el2/public_html/account/application/controllers/Welcome.php Line: 105 Function: send
文件:/home/b4ger7ik8el2/public_html/account/application/controllers/Welcome.php行:105功能:发送
File: /home/b4ger7ik8el2/public_html/account/index.php Line: 315 Function: require_once
文件:/home/b4ger7ik8el2/public_html/account/index.php行:315功能:require_once
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Email', // change it to yours
'smtp_pass' => 'Pasword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = "
<html>
<head>
<title>Verification Code</title>
</head>
<body>
<h2>Thank you for Registering.</h2>
<p>Dear:".$this->input->POST('firstname')."</p>
<p>Email: ".$this->input->POST('user_email')."</p>
<p>Please click the link below to activate your account.</p>
<h4><a href='".base_url()."welcome/activate/".$email=$this->input->POST('user_email')."/'>Activate My Account</a></h4>
</body>
</html>
";
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($config['smtp_user']);
$this->email->to($this->input->POST('user_email'));
$this->email->subject('Signup Verification Email');
$this->email->message($message);
//sending email
if($this->email->send()){
$this->session->set_flashdata('Success','Your Account Has Been Created Please Check your email and verify your account..!');
}
else{
$this->session->set_flashdata('message', $this->email->print_debugger());
}
You just need to remove the SSL part from your SMTP string in the config array, 您只需要从config数组中的SMTP字符串中删除SSL部分,
config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Email', // change it to yours
'smtp_pass' => 'Pasword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
just do 做就是了
config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Email', // change it to yours
'smtp_pass' => 'Pasword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
to 至
config = array(
'protocol' => 'mail',
'smtp_host' => 'smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Email', // change it to yours
'smtp_pass' => 'Pasword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
Now it will surely work for you. 现在肯定会为您工作。 As it worked for me.
因为它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.