1

Codeigniter と Ion Auth Library を使用するサイトを作成しています。

登録/ログイン/忘れたパスワードを設定しましたが、これらはすべて忘れたパスワードの設定の問題とは別に機能します。

ユーザーの電子メール アドレスが hotmail、yahoo、gmail などを使用している場合、電子メールを正常に受信し、パスワードをリセットしてデータベース内のデータを変更できます。

Outlook とメールでこのメールを受信する個人ドメインのメール アドレスに問題があるため、Exchange と関係があるように見えますか?

また、Outlook を搭載したコンピューターでログ設定を有効にしました。テスト送信時にメールがログに記録されないため、メールがブロックされているわけではありません。

今、私は電子メール構成設定の配列を持っていますが、それがホスト、プロトコル、ヘッダーと関係があるかどうかはわかりません?! またはその他の設定ですが、私が持っているものに以下の情報を提供します。誰かが情報、リンク、スニペット、またはアイデアを持っている場合、これは大きな助けになります.

Ion Auth を使用して、コードを元の場所に保持し、構成ファイルの設定に変更しました。

設定

   $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);
    }

パスワードを忘れた場合のライブラリ関数:

/**
     * 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;
        }
    }
4

2 に答える 2

0

必要な正確な構成がわかりません。ここにあるのは、 CI メール ライブラリで使用する独自のsend_mail()関数です。それはあなたを助けるかもしれません。ただし、私は常に ION AUTH を使用しており、メールの送信で問題が発生したことはありません。

/*
 * Send an email. 
 * $info array must have following information :
 * $info = array(
 *      'to_email'      => 
 *      'to_name'       =>
 *      'from_email'    =>
 *      'from_name'     =>
 *      'subject'       =>
 *      'body'          =>
 *      'reply_to'      =>
 * )
 */
if ( ! function_exists('send_email'))
{
    function send_email($info)
    {
        $CI = & get_instance();

        // ==========================================================================================
        $CI->load->library('email');

        $config['protocol'] = 'sendmail';
        $config['charset'] = 'iso-8859-1';
        $config['wordwrap'] = TRUE;
        $config['mailtype'] = 'html';

        $CI->email->initialize($config);

        $CI->email->clear();
        $CI->email->set_newline("\r\n");
        // =========================================================================================

        $CI->email->from($info['from_email'], $info['from_name']);
        $CI->email->to($info['to_email'], $info['to_name']);
        $CI->email->cc('mahbub.kuet@gmail.com', 'MAHBUB');

        $CI->email->subject($info['subject']);
        $CI->email->message($info['body']);

        $CI->email->reply_to($info['reply_to'], "No reply");

        if($CI->email->send()) return TRUE;

        return FALSE;   
    }    
}
于 2013-03-22T05:42:32.677 に答える
0

現時点でも同じ問題がありました。このフォーラムの投稿に基づいた私のソリューションは、このエラーを理解するのに本当に役立ちました。

http://ellislab.com/forums/viewreply/785297/

私の場合、問題は、リポジトリの言語ファイルを使用した IonAuth の多言語セットアップでした。ドイツ語の言語ファイルには、'email_forgotten_password_subject' 言語行の特殊文字 'ü' があります。

Codeigniter メール クラスは、サブジェクトの構成からのエンコーディングを使用していません。そのため、specialchar が正しくエンコードされず、smtp_mailer エラーが発生しました。

私はファイル application/libraries/MY_Email.php を作成して、このコンテンツで使用されるサブジェクト セッター メソッドをフックしました。

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Email extends CI_Email
{
    /**
     * Set Email Subject
     *
     * @access    public
     * @param    string
     * @return    void
     */
    function subject($subject)
    {
        $subject = '=?'. $this->charset .'?B?'. base64_encode($subject) .'?=';
        $this->_set_header('Subject', $subject);
    }
} 

これで、Mailclass は Subject を正しい方法でエンコードし、週末に向けてビールを飲みます。

私のソリューションがあなたの問題と一致することを願っています。

乾杯

于 2014-02-14T18:44:12.890 に答える