0

I have following function which works on localhost but it does't work on live server godaddy. It throws warning :

fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection refused)

This is my model function

  public function check()
    {
        $name   = 'sangram';
        $email  = 'sangram.preciseit@gmail.com';
        $phone  = '12456789';
        $message= 'testing';

        $to = 'sangram.preciseit@gmail.com';
        $sub = 'Enquiry';
        $msg="<p>Name:$name</p><p>Email: $email</p><p>Contact Number: $phone</p><p>Message: $message</p>";

        $configGmail = array();
        $configGmail['protocol']        = 'smtp';
        $configGmail['smtp_host']    = 'ssl://smtp.googlemail.com';
        $configGmail['smtp_port']    = '465';
        $configGmail['mailtype']        = 'html';
        $configGmail['charset']     = 'utf-8';
        $configGmail['newline']     = "\r\n";

        // new mailid chnaged on 1st-dec-2016
        $configGmail['smtp_user']    = 'emailaddress@gmail.com';
        $configGmail['smtp_pass']    = 'mypassword';

        $configGmail['wordwrap']    = TRUE;

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

        $this->email->from('emailaddress@gmail.com',"XYZ");

        $this->email->to($to);
        $this->email->subject($sub);
        $msg    =   $msg;
        $this->email->message($msg);

        if($this->email->send())
        {
            echo "mail send";
        }
        else{
            echo "mail not send";
        }
    }

Please tell me what should i do? Thanks in advance

Smit Mehta
  • 196
  • 1
  • 10

1 Answers1

0

Please remove the ssl from ssl://smtp.googlemail.com.

Change the config array , add smtp_crypto and set its value to ssl

    $configGmail = array();
    $configGmail['protocol']    = 'smtp';
    $configGmail['smtp_host']   = 'smtp.googlemail.com';
    $configGmail['smtp_port']   = '465';
    $configGmail['mailtype']    = 'html';
    $configGmail['charset']     = 'utf-8';
    $configGmail['newline']     = "\r\n";


    $configGmail['smtp_user']    = 'emailaddress@gmail.com';
    $configGmail['smtp_pass']    = 'mypassword';
    $configGmail['smtp_crypto']  = 'ssl';  
    $configGmail['wordwrap']     = TRUE;

Hope this helps.

Smit Mehta
  • 196
  • 1
  • 10