-1

I'm trying to run this code :

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

When I tried to send, I got this error:

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

What caused this? How can I resolve it?

Justin Morgan - On strike
  • 30,035
  • 12
  • 80
  • 104
Anudeep GI
  • 931
  • 3
  • 14
  • 45

3 Answers3

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.

L0j1k
  • 12,255
  • 7
  • 53
  • 65
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`.**
Abhishek
  • 31
  • 8
0

try this,its working for me....

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

then open your php.ini and go to extension=php_openssl.dll and un comment this line . after that restart ur wamp server.

User
  • 360
  • 3
  • 4
  • 18