試圖爲我的網站設置一個重置密碼功能,但是我無法通過發送郵件而沒有發生此錯誤。用google和codeigniter發送smtp電子郵件時出錯
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
我使用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('[email protected]', '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');
}
我也收到此錯誤::
Message: Undefined index: Subject
我不明白爲什麼會這樣,你可以請幫我謝謝你。
感謝您的回覆解決了這個問題,但是我仍然遇到錯誤,因爲遇到了以下SMTP錯誤:首先是503 5.5.1 RCPT。 z10sm7618335wfj.12 502 5.5.1無法識別的命令。 z10sm7618335wfj.12 遇到以下SMTP錯誤:502 5.5.1無法識別的命令。 z10sm7618335wfj.12 無法使用PHP SMTP發送電子郵件。您的服務器可能未配置爲使用此方法發送郵件.' – matthew 2011-04-25 10:38:59
您確定端口在465處是否正確? – Dormouse 2011-04-25 10:43:06
嘗試更改'$ config ['smtp_port'] ='465''到'$ config ['smtp_port'] = 465' – Dormouse 2011-04-25 10:47:09