Codeigniter 3 send email without smtp

前端 未结 1 979
野趣味
野趣味 2021-01-14 22:03

I am not receiving an email, though everything seems fine. May be hosting issue? Any suggestion will be appreciated. Here is my code

    $this->load->l         


        
相关标签:
1条回答
  • 2021-01-14 22:35

    Perfect solution is as below:

    Step 1:

    Download PhpMailer for CodeIgniter from below link.

    https://github.com/ivantcholakov/codeigniter-phpmailer

    Step 2:

    Extract. Put third_party, libraries, helpers and config folder into your CI application folder.

    There will just index file(s) in each folder that will ask you to replace. Click replace and continue.

    Step 3:

    Open application/config/email.php

    And do some updates according to your email account. I am using gmail, so I am giving gmail settings as below.

    $config['protocol']         = 'smtp'; // 'mail', 'sendmail', or 'smtp'
    $config['mailpath']         = '/usr/sbin/sendmail';
    $config['smtp_host']        = 'smtp.gmail.com'; // if you are using gmail
    $config['smtp_user']        = 'youremail@gmail.com';
    $config['smtp_pass']        = 'sdkfjsk089sdfskKJ'; // App specific password
    $config['smtp_port']        = 465; // for gmail
    $config['smtp_timeout']     = 5;  
    

    Step 4:

    Now, in your controller where you want to send email. Use below code and its all done.

    $this->load->library('email');
    $this->email->from('youremail@gmail.com')
         ->reply_to('youremail@gmail.com')
         ->to(someone@somedomain.com)
         ->subject("Subject")
         ->message("Your Message")
         ->set_mailtype('html')
         ->send();
    
    0 讨论(0)
提交回复
热议问题