我得到的错误
严重性:警告消息:fsockopen():无法连接到ssl://smtp.gmail.com:465(连接被拒绝)
文件名:libraries/Email.php
这是我的控制器功能:
public function contactload(){
// to load the register.php
// here the data is stored to database
$this->load->model('User_model');
//storing the data into the array
$formArray =array();
$formArray['name']= $this->input->post('name');
$formArray['email']= $this->input->post('email');
$formArray['country']= $this->input->post('country');
$formArray['subject']= $this->input->post('subject');
// calling the create function in user_model
$check=$this->User_model->create($formArray);
if($check==true){
if ($this->User_model->sendEmail($this->input->post('email'), $this->input->post('name')))
{
// successfully sent mail
echo '<script>alert("Mail Is sent kindly check the Mail")</script>';
} else {
// error
echo '<script>alert("UNABLE TO SEND THE MAIL")</script>';
}
}else{
echo "error !";
}
}
模型:
public function sendEmail($to_email,$name) {
$from_email = '*********@gmail.com'; //change this to yours
$subject = 'Your meaasge Has Sucessfully reached Us';
$message = ' <html> <head> <title>Conformation Mail</title> </head> <body>
$this->load->library('email');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => '465',
'smtp_user' => '***************@gmail.com',
'smtp_pass' => '****************',
'mailtype' => 'html',
'smtp_timeout' => '60',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE,
'newline' => "\r\n"
);
$this->load->library('email',$config);
$this->email->initialize($config);
//send mail
$this->email->from($from_email);
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($message);
return $this->email->send();
echo $this->email->print_debugger();
}
邮件发送操作在本地主机上工作,但在活动服务器上不工作
这是一个代码点火器项目
1条答案
按热度按时间ufj5ltwl1#
您需要使用$_SERVER ['REMOTE_ADDR']变量来获取服务器的地址。
在Controller中,您必须执行以下操作:
现在使用控制器功能发送电子邮件。