Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';不要发送电子邮件_Php_Codeigniter - Fatal编程技术网

Php Can';不要发送电子邮件

Php Can';不要发送电子邮件,php,codeigniter,Php,Codeigniter,我尝试使用CodeIgniter的电子邮件类发送邮件,但它显示了一些错误: 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?) 我的代码在这里: $config['p

我尝试使用CodeIgniter的电子邮件类发送邮件,但它显示了一些错误:

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?)
我的代码在这里:

        $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();

我还更改了php.ini文件,并在其中粘贴了
extension=php_openssl.dll
,但它仍然不起作用。

gmail的smtp服务器是smtp.gmail.com

因此,您的配置应该是:

$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';

但我不确定smtp_主机是否需要“ssl://”部分

phpinfo()是否显示已启用fsockopen?我认为您是通过web应用程序而不是在命令行运行此操作的?(请确保您修改了正确的php.ini文件——上述每个环境通常都有一个)。