![](/img/trans.png)
[英]Codeigniter 3 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method
[英]Unable to send email using codeigniter-Error:Your server might not be configured to send mail using this method
我正在尝试使用域电子邮件ID从实时服务器发送电子邮件。 每当遇到相同的错误时,我尝试使用不同的端口ID。我的控制器代码如下所示:
public function send_mail() {
$this->load->library('email');
$name = $this->input->post("name");
$email = $this->input->post("email");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.*******.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'info@*******.com';
$config['smtp_pass'] = '*********';
$config['charset'] = 'utf-8';
$config['newline'] = '\r\n';
$config['mailtype'] = 'text'; // or html
$config['validation'] = TRUE;
$this->email->initialize($config);
$this->email->from('info@*******.com', 'Hima');
$this->email->to($email);
$this->email->subject('email verification');
$this->email->message('Verification Code');
$send = $this->email->send();
if ($send) {
$this->session->set_flashdata('msg','success');
} else {
echo $error = $this->email->print_debugger();
}
}
$this->load->library('email');
//SMTP & mail configuration
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'example@gmail.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->email->initialize($config);
$this->email->from('info@*******.com', 'Hima');
$this->email->to($email);
$this->email->subject('email verification');
$this->email->message('Verification Code');
$send = $this->email->send();
if ($send) {
$this->session->set_flashdata('msg','success');
} else {
echo $error = $this->email->print_debugger();
}
我已经配置如下:
public function send_mail() {
$this->load->library('encrypt');
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => '465',
'smtp_user' => '*****@gmail.com',
'smtp_pass' => '**********',
'smtp_crypto' => 'ssl',
'crlf' => "\r\n",
);
$this->load->library('email',$config);
$send = $this->email->send();
if ($send) {
return $send;
} else {
$error = show_error($this->email->print_debugger());
return $error;
}
}
希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.