2

Android アプリの Web サービスを開発していますが、メール機能がうまく動作しません。このチュートリアルに従ってくださいHERE .

そして私のコントローラーにはこれがあります:

function forgotPassword_get(){
        $this->load->model('model');
        
        $this->response->format = 'json';
        
        $email = $this->get('email');
    
    $config['protocol'] = 'sendmail';
    $config['mailpath'] = '/usr/sbin/sendmail';
    $config['charset'] = 'iso-8859-1';

    // gmail specific settings here
    $config['smtp_host'] = 'smtp.gmail.com';
    $config['smtp_user'] = 'my email here';
    $config['smtp_pass'] = 'password here';
    $config['smtp_port'] = '465';

    $config['wordwrap'] = TRUE;

    $this->load->library('email');
    $this->email->initialize($config);
    
        $this->email->from('mailfrom', 'sample name');
        $this->email->to('mailto'); 

        $this->email->subject('sample email');
        $this->email->message('sample message for email.'); 

        $this->email->send();

        echo $this->email->print_debugger();
        
    }

結果は

Your message has been successfully sent using the following protocol: sendmail
    User-Agent: CodeIgniter
    Date: Tue, 29 Oct 2013 15:45:57 +0800
    From: "sample name" 
    X-Mailer: CodeIgniter
    X-Priority: 3 (Normal)
    Message-ID: <526f67b5f16b8@mobilemo.com>
    Mime-Version: 1.0
    Content-Type: text/plain; charset=iso-8859-1
    Content-Transfer-Encoding: 8bit

sample message for email.

メールは正常に送信されたと表示されますが、メールが受信トレイに届いていないようです。

誰かが私を助けてくれますか、私は何かを逃したと思います。前もって感謝します。

4

2 に答える 2

2

あなたはこれを試してみたいかもしれません:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'emailhere@gmail.com';
$config['smtp_pass'] = 'password Here';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "\r\n";

$this->load->library('email');
$this->email->initialize($config);

設定項目を変更しました。それが役に立てば幸い。

于 2013-10-29T10:47:53.897 に答える
0

Gmail で SMTP アクセスを有効にしましたか? 私の記憶が正しければ、「サード パーティがこのアカウントを使用してメールを送信することを許可する」などの Gmail のチェックボックスをクリックする必要があります。また、誰かがあなたのアカウントにアクセスしようとすると、Gmail が常に警告するため、これはお勧めできません。

于 2013-10-29T08:02:42.520 に答える