我正在創建一個使用Codeigniter和Ion Auth Library的網站。PHP:電子郵件只適用於某些電子郵件客戶端
我已經設置了一個註冊/登錄/忘記密碼,除了忘記密碼設置的問題之外,這些密碼都可以使用。
如果用戶的電子郵件地址是使用hotmail,yahoo,gmail等他們收到的電子郵件罰款,可以重置密碼和數據庫中的數據更改。
我在接收此電子郵件的個人域名電子郵件地址在Outlook和Mail中遇到問題,因此它看起來可能與Exchange有關?
我還啓用了具有Outlook的計算機上的日誌設置,並且在測試發送電子郵件時什麼也沒有記錄,所以它不像它阻止電子郵件。
現在我有一個數組的電子郵件配置設置,我不確定它是否可以與主機,協議,頭文件?或任何其他設置,但我會提供一些信息,以我的東西。如果任何人有任何信息,鏈接,片段或想法,這將是一個很大的幫助。
對於使用離子驗證我剛纔一直在那裏它是,它改變了我的配置文件設置代碼:
CONFIG
$config['use_ci_email'] = FALSE; // Send Email using the builtin CI email class, if false it will return the code and the identity
$config['email_config'] = array(
'protocol'=> 'mail',
'mailtype' => 'html',
'charset' =>'utf-8',
'smpt_host' =>'smpt.url.com',
'smpt_user'=> 'ssl://smtp.live.com',
'smtp_port' => '25',
'validate' => TRUE,
'priority' => 1
);
控制器,用於忘記密碼:
//forgot password
function forgot_password() {
$this->form_validation->set_rules('email', 'Email Address', 'required');
if ($this->form_validation->run() == false) {
//setup the input
$this->data['email'] = array('name' => 'email',
'id' => 'email',
);
if ($this->config->item('identity', 'ion_auth') == 'username'){
$this->data['identity_label'] = 'Username';
}else{
$this->data['identity_label'] = 'Email';
}
//set any errors and display the form
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->_render_page('forgot_password', $this->data);
}else{
// get identity for that email
$config_tables = $this->config->item('tables', 'ion_auth');
$identity = $this->db->where('email', $this->input->post('email'))->limit('1')->get($config_tables['users'])->row();
//run the forgotten password method to email an activation code to the user
$forgotten = $this->ion_auth->forgotten_password($identity->{$this->config->item('identity', 'ion_auth')});
if ($forgotten) {
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("login", 'refresh'); //we should display a confirmation page here instead of the login page
}else{
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("forgot_password", 'refresh');
}
}
}
function _get_csrf_nonce() {
$this->load->helper('string');
$key = random_string('alnum', 8);
$value = random_string('alnum', 20);
$this->session->set_flashdata('csrfkey', $key);
$this->session->set_flashdata('csrfvalue', $value);
return array($key => $value);
}
庫函數for得到密碼:
/**
* forgotten password feature
**/
public function forgotten_password($identity) //changed $email to $identity
{
if ($this->ion_auth_model->forgotten_password($identity)) //changed
{
// Get user information
$user = $this->where($this->config->item('identity', 'ion_auth'), $identity)->users()->row(); //changed to get_user_by_identity from email
if ($user)
{
$data = array(
'identity' => $user->{$this->config->item('identity', 'ion_auth')},
'forgotten_password_code' => $user->forgotten_password_code
);
if(!$this->config->item('email_config', 'ion_auth'))
{
$this->set_message('forgot_password_successful');
return $data;
}
else
{
$message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password', 'ion_auth'), $data, true);
$this->email->clear();
$this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
$this->email->to($user->email);
$this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgotten_password_subject'));
$this->email->message($message);
if ($this->email->send())
{
$this->set_message('forgot_password_successful');
return TRUE;
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
你看過在host.url.com上的電子郵件日誌嗎?您是否使用電子郵件直播?如果是這樣,你有權訪問開發郵件服務器進行測試嗎? – LeonardChallis 2013-02-15 11:52:58我目前正在本地主機上開發,也上傳到服務器上,沒有收到相關信息。當調試它說的是電子郵件發送,但表示電子郵件可能無法讀取MIME編碼的電子郵件 - 不知道這是我可以改變我的配置文件?還嘗試了純文本,將所有內容都鑲嵌到後面,但仍然不是運氣甚至錯誤。我使用了@ hotmail.co.uk,並且在Outlook Live瀏覽器,Gmail瀏覽器和雅虎瀏覽器中收到了該電子郵件。我不幸的是無法訪問開發郵件服務器。 – Shimsham84 2013-02-15 12:02:33
您可以在本地安裝類似hMail Server的服務器來測試郵件本地發送嗎?你真的可以看到郵件服務器的實際日誌。 – LeonardChallis 2013-02-15 12:04:35