简体   繁体   中英

Can't send email

I tried to send mail using the email class of CodeIgniter, but it is showing some errors:

fsockopen() [function.fsockopen]: unable to connect to
ssl://smtp.googlemail.com:465 (Unable to find the socket transport
"ssl" - did you forget to enable it when you configured PHP?)

My code is here:

        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'ssl://smtp.googlemail.com';
        $config['smtp_port'] = 465;
        $config['smtp_user'] = 'myemail.world2010@gmail.com';
        $config['smtp_pass'] = 'email';

        $this->load->library('email');
        $this->email->initialize($config);
        $this->email->set_newline("\r\n");        
       $message="
           username:{$this->input->post('username')}
           password:{$this->input->post('password')}
            ";
       $this->email->from('sagar.world2010@gmail.com','Admin');
       $this->email->to($this->input->post('email'));
       $this->email->subject('Activation Message');
       $this->email->message($message);
       $this->email->send();
       echo $this->email->print_debugger();

I also changed the php.ini file and pasted extension=php_openssl.dll in it, but it still does not work.

The smtp server from gmail is smtp.gmail.com

so your configuration should be:

$config['protocol'] = 'smtp';  
$config['smtp_host'] = 'ssl://smtp.gmail.com';  
$config['smtp_port'] = 465;  
$config['smtp_user'] = 'myemail.world2010@gmail.com';
$config['smtp_pass'] = 'email';

but I'm not sure if smtp_host need the 'ssl://' part

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