2
votes

I'm try to sending email using SMTP server with codeIgniter
i have code and its working fine on localhost but not on server, i have done lots of research and try many code but it's still not working.

$config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => '[email protected]',
        'smtp_pass' => 'xxxxxxx',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");

    $this->email->from('[email protected]', 'Blabla');
    $list = array('[email protected]','[email protected]');
    $this->email->to($list);
    $this->email->reply_to('[email protected]', 'Explendid Videos');
    $this->email->subject('This is an email test');
    $this->email->message('It is working. Great!');

    $result = $this->email->send();

Error-
The following SMTP error was encountered: 111 Connection refused Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

1
I also try mandrill and sendgrid SMTP config but it's not working. - sandy
if its on a localhost? If so you may need to set up your send email config on what ever your local host xampp tutorial youtube.com/watch?v=TO7MfDcM-Ho - Mr. ED

1 Answers

0
votes

please edit your autoload to

$autoload['libraries'] = array('database','email');

please advise if you are still getting an error...