简体   繁体   中英

Sending email to gmail with CodeIgniter displays “message sent” but there nothing in the inbox?

I'm following this amazing nettusts+ tutorial about sending a email to gmail.

It aparently worked. When I load the page it says: 'Your email was sent, fool.' but then I check my gmail and there's nothing there.

Does CodeIgniter take care of everything? Or I have to install smtp or something in my PC because I'm using localhost (LAMP in Ubuntu)?

Code:

/* SEND EMAIL WITH GMAIL */

class Email extends Controller {

    function __construct()
    {
        parent::Controller();
    }

    function index()
    {
        $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'janoochen@gmail.com',
            'smtp_pass' => '***',
        );

        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");

        $this->email->from('janoochen@gmal.com', 'Alex Chen');
        $this->email->to('janoochen@gmal.com');
        $this->email->subject('This is an email');
        $this->email->message('It is working. Great!');

        if($this->email->send())
        {
            echo 'Your email was sent, fool.';
        }

        else
        {
            show_error($this->email->print_debugger());
        }
    }
}

我不知道这是不是,但是在您的代码中,您有@gmal.com而不是@gmail.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM