我在CodeIgniter中尝试并开发了一个具有邮件发送功能的应用程序。 早期邮件有效,但邮件没有发送。 没有报告错误。它说邮件发送成功,但我还没有收到邮件。
控制器代码:
public function mail() {
$from_email = "tamilshanmugamit460@gmail.com";
//Load email library
$this->load->library('email');
$this->email->from($from_email, 'Your Name');
$this->email->to($from_email);
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
//Send mail
if($this->email->send())
echo "Email sent successfully.";
else
echo "Error in sending Email.";
}
答案 0 :(得分:0)
使用此方法希望它能为您提供帮助
电子邮件配置
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = "user-email";
$config['smtp_pass'] = "password";
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html';
$this->email->initialize($config);
电子邮件发送代码
$this->email->from('your-email', 'Name');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($message);
$this->email->send()