-1

我正在尝试运行此代码:

    $this->load->library('email');

    $this->email->from('anu1488@gmail.com', 'Anudeep');

    $this->email->to('anu1488@gmail.com');

    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');

    $this->email->send();

    echo $this->email->print_debugger();

当我尝试发送时,我收到了这个错误:

A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()    
Filename: libraries/Email.php
Line Number: 1553

这是什么原因造成的?我该如何解决?

4

3 回答 3

0

It sounds like you do not have an SMTP server (mail server) set up on your local machine to send out email. It sounds like the libraries/Email.php file is referencing a hostname/port where a valid mail server does not live.

于 2012-12-20T05:05:14.203 回答
0
**I guess you need to setup email configuration and port number in  config/email  .**

 $config['protocol']='smtp';
 $config['smtp_host']='ssl://smtp.googlemail.com';
 $config['smtp_port']='465';
 $config['smtp_timeout']='30';
 $config['smtp_user']='abhi.abc@gmail.com';
 $config['smtp_pass']='password';
 $config['charset']='utf-8';
 $config['newline']="\r\n";
 $config['mailtype'] = "html";


**if every thing is correct from your side then you can just change 'smtp_port' number and then check it definitely it will work`enter code here`.**
于 2012-12-20T06:11:57.187 回答
0

试试这个,它对我有用....

$config = Array(
                    'protocol' => 'smtp',
                    'smtp_host' => 'ssl://smtp.googlemail.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'user@gmail.com',
                    'smtp_pass' => 'user password',
                );


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

                $this->email->from('user@gmail.com', 'User');
                $this->email->to(sample@gmail.com);


                $this->email->subject('Email Test');
                $this->email->message('Testing the email class.');

                if ($this->email->send()) {
                    $data['error'] = "Your email was sent";
                } else {
                    show_error($this->email->print_debugger());
                }

然后打开您的 php.ini 并转到extension=php_openssl.dll并取消注释此行。之后重新启动你的 wamp 服务器。

于 2013-01-28T07:28:15.383 回答