2016-12-08 1 views
0

ここまで簡単に説明します。 私はcodeigniterライブラリを使用してメールを送信しようとしています。 しかし、私は電子メールを受信して​​いないと私のコードに表示されるエラーはありません。 なぜ動作しないのかわかりません。CI SMTPを使用したメールの送信

また、私は設定を省略したときに2 step verificationallow access to less secure apps

はしかし、それは私にスパムのセクションに直接行く電子メールを送信続いてきました。私はなぜそれが迷惑メールのセクションに行くのかわかりません。コメントリンクの答えが動作しない場合にも、このコードを試すことができます

public function sending_email(){ 

    // The mail sending protocol. 
    $config['protocol'] = 'smtp'; 
    // SMTP Server Address for Gmail. 
    $config['smtp_host'] = 'ssl://smtp.googlemail.com'; 
    // SMTP Port - the port that you is required 
    $config['smtp_port'] = '465'; 
    // SMTP Username like. ([email protected]) 
    $config['smtp_user'] = '[email protected]'; 
    // SMTP Password like (abc***##) 
    $config['smtp_pass'] = '****'; 
    // Load email library and passing configured values to email library 
    $this->load->library('email', $config); 
    // Sender email address 
    $this->email->from('[email protected]', 'sample'); 
    // Receiver email address.for single email 
    $this->email->to('[email protected]'); 
    //send multiple email 
    //$this->email->to([email protected],[email protected],jk[email protected]); 
    // Subject of email 
    $this->email->subject('test'); 
    // Message in email 
    $this->email->message('hello world!'); 
    // It returns boolean TRUE or FALSE based on success or failure 
    echo $this->email->send(); 

} 
+0

私はsmtpサーバーが「smtp.gmail.com」https://support.google.com/a/answer/176600?hl=enである必要があります.2段階認証を使用している場合は、アプリ固有のパスワードhttps://support.google.com/accounts/answer/185833?hl=jaを使用します。そのことが分かれば教えてください。 – Morfinismo

+0

@Morfinismoはまったく動作しません。あなたが提案したことを試してみました.. –

+0

私は、あなたの複製のように見えるこの質問で提供される回答を調べることをお勧めします。http://stackoverflow.com/questions/1555145/sending-email-with-gmail-smtp-with-codeigniter-メールライブラリ – Morfinismo

答えて

1

は、ここに私のコードです。

$config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.googlemail.com', 
     'smtp_port' => 465, 
     'smtp_user' => 'xxx', 
     'smtp_pass' => 'xxx', 
     'mailtype' => 'html', 
     'charset' => 'iso-8859-1' 
    ); 
    $this->load->library('email', $config); 
    $this->email->set_newline("\r\n"); 
    // Set to, from, message, etc. 

    $result = $this->email->send(); 
関連する問題