【发布时间】:2011-04-28 12:01:09
【问题描述】:
尝试为我的网站设置重置密码功能,但是如果没有发生此错误,我无法通过发送电子邮件。
无法使用 PHP mail() 发送电子邮件。 您的服务器可能未配置为 使用此方法发送邮件。
我使用 gmail 作为主机发送电子邮件。这是用于发送电子邮件的函数部分。
$user_email = $this->input->post('email_address');
$query = $this->db->get_where('account', array('email_address' => $user_email));
if($query) {
$config['protocal'] = 'smtp';
$config['mail_path'] = 'ssl://smtp.googlemail.com';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'USEREMAIL';
$config['smtp_pass'] = 'PASSWORD';
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$this->email->initialize($config);
$this->email->from('matthew.attanasio135@gmail.com', 'Matthew');
$this->email->to($user_email);
$this->email->subject('Email Test');
$this->email->message('<h1>Testing the email class.<h1>');
$this->email->send();
if ( ! $this->email->send()) {
show_error($this->email->print_debugger());
}
else {
echo('DONE');
}
我也收到此错误::
消息:未定义索引:主题
我不明白为什么会发生这种情况,请您帮帮我谢谢。
【问题讨论】:
标签: php email codeigniter smtp gmail