Codeigniter : Unable to Send Email via SMTP Google always got Connection Refused











up vote
0
down vote

favorite












I am struggling in how to send email by using smtp gmail.



This error always happens to me,




[message:protected] => fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
[string:Exception:private] =>
[code:protected] => 2
[file:protected] => /home/u6676613/public_html/testing/system/libraries/Email.php
[line:protected] => 1689
[trace:Exception:private] => Array



Below is my configuration for sending the email



    $config['protocol']='smtp';  

$config['smtp_host']='ssl://smtp.gmail.com' ;

$config['smtp_port']='465';
//$config['smtp_crypto'] = 'ssl';
$config['smtp_timeout']='30';
$config['smtp_user']=$smtp_username;
$config['smtp_pass']=$smtp_password;
$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';

$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';
$this->load->library('email');
$this->email->initialize($config);


$this->email->from('do-not-reply@blabla.com');
$this->email->to($email);
$this->email->subject('Testing');
$this->email->message($msg);
if($this->email->send())
{


$this->success();
}
else
{
show_error($this->email->print_debugger());
}


If i try to uncomment smtp crypto, i got error " fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known"



FYI ssl extension already enabled.
Kindly need your help for this matter



My problem is not ssl extension related so i think its not duplicate with another issue










share|improve this question
























  • Try removing ssl:// part from host parameter perhaps and see if it works (also uncomment smtp_crypto then)
    – p0358
    Nov 18 at 21:32












  • uncomment smtp crypto and run in terminal setsebool httpd_can_network_connect=1
    – user969068
    Nov 18 at 22:37












  • i've tried uncomment smtp crypto and remove ssl:// still got same error message "fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)"
    – Shandy Kurnia
    Nov 19 at 1:10










  • Possible duplicate of fsockopen(): unable to connect to ssl://smtp.gmail.com:465
    – Twinkle
    Nov 19 at 4:33










  • what do you mean by duplicate ? If im using another smtp server, it works. but if im using smtp google, i always get this error
    – Shandy Kurnia
    Nov 19 at 7:34















up vote
0
down vote

favorite












I am struggling in how to send email by using smtp gmail.



This error always happens to me,




[message:protected] => fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
[string:Exception:private] =>
[code:protected] => 2
[file:protected] => /home/u6676613/public_html/testing/system/libraries/Email.php
[line:protected] => 1689
[trace:Exception:private] => Array



Below is my configuration for sending the email



    $config['protocol']='smtp';  

$config['smtp_host']='ssl://smtp.gmail.com' ;

$config['smtp_port']='465';
//$config['smtp_crypto'] = 'ssl';
$config['smtp_timeout']='30';
$config['smtp_user']=$smtp_username;
$config['smtp_pass']=$smtp_password;
$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';

$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';
$this->load->library('email');
$this->email->initialize($config);


$this->email->from('do-not-reply@blabla.com');
$this->email->to($email);
$this->email->subject('Testing');
$this->email->message($msg);
if($this->email->send())
{


$this->success();
}
else
{
show_error($this->email->print_debugger());
}


If i try to uncomment smtp crypto, i got error " fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known"



FYI ssl extension already enabled.
Kindly need your help for this matter



My problem is not ssl extension related so i think its not duplicate with another issue










share|improve this question
























  • Try removing ssl:// part from host parameter perhaps and see if it works (also uncomment smtp_crypto then)
    – p0358
    Nov 18 at 21:32












  • uncomment smtp crypto and run in terminal setsebool httpd_can_network_connect=1
    – user969068
    Nov 18 at 22:37












  • i've tried uncomment smtp crypto and remove ssl:// still got same error message "fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)"
    – Shandy Kurnia
    Nov 19 at 1:10










  • Possible duplicate of fsockopen(): unable to connect to ssl://smtp.gmail.com:465
    – Twinkle
    Nov 19 at 4:33










  • what do you mean by duplicate ? If im using another smtp server, it works. but if im using smtp google, i always get this error
    – Shandy Kurnia
    Nov 19 at 7:34













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am struggling in how to send email by using smtp gmail.



This error always happens to me,




[message:protected] => fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
[string:Exception:private] =>
[code:protected] => 2
[file:protected] => /home/u6676613/public_html/testing/system/libraries/Email.php
[line:protected] => 1689
[trace:Exception:private] => Array



Below is my configuration for sending the email



    $config['protocol']='smtp';  

$config['smtp_host']='ssl://smtp.gmail.com' ;

$config['smtp_port']='465';
//$config['smtp_crypto'] = 'ssl';
$config['smtp_timeout']='30';
$config['smtp_user']=$smtp_username;
$config['smtp_pass']=$smtp_password;
$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';

$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';
$this->load->library('email');
$this->email->initialize($config);


$this->email->from('do-not-reply@blabla.com');
$this->email->to($email);
$this->email->subject('Testing');
$this->email->message($msg);
if($this->email->send())
{


$this->success();
}
else
{
show_error($this->email->print_debugger());
}


If i try to uncomment smtp crypto, i got error " fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known"



FYI ssl extension already enabled.
Kindly need your help for this matter



My problem is not ssl extension related so i think its not duplicate with another issue










share|improve this question















I am struggling in how to send email by using smtp gmail.



This error always happens to me,




[message:protected] => fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
[string:Exception:private] =>
[code:protected] => 2
[file:protected] => /home/u6676613/public_html/testing/system/libraries/Email.php
[line:protected] => 1689
[trace:Exception:private] => Array



Below is my configuration for sending the email



    $config['protocol']='smtp';  

$config['smtp_host']='ssl://smtp.gmail.com' ;

$config['smtp_port']='465';
//$config['smtp_crypto'] = 'ssl';
$config['smtp_timeout']='30';
$config['smtp_user']=$smtp_username;
$config['smtp_pass']=$smtp_password;
$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';

$config['charset']='utf-8';
$config['newline']="rn";
$config['mailtype'] = 'html';
$this->load->library('email');
$this->email->initialize($config);


$this->email->from('do-not-reply@blabla.com');
$this->email->to($email);
$this->email->subject('Testing');
$this->email->message($msg);
if($this->email->send())
{


$this->success();
}
else
{
show_error($this->email->print_debugger());
}


If i try to uncomment smtp crypto, i got error " fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known"



FYI ssl extension already enabled.
Kindly need your help for this matter



My problem is not ssl extension related so i think its not duplicate with another issue







php codeigniter email smtp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 1:51

























asked Nov 18 at 21:05









Shandy Kurnia

96




96












  • Try removing ssl:// part from host parameter perhaps and see if it works (also uncomment smtp_crypto then)
    – p0358
    Nov 18 at 21:32












  • uncomment smtp crypto and run in terminal setsebool httpd_can_network_connect=1
    – user969068
    Nov 18 at 22:37












  • i've tried uncomment smtp crypto and remove ssl:// still got same error message "fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)"
    – Shandy Kurnia
    Nov 19 at 1:10










  • Possible duplicate of fsockopen(): unable to connect to ssl://smtp.gmail.com:465
    – Twinkle
    Nov 19 at 4:33










  • what do you mean by duplicate ? If im using another smtp server, it works. but if im using smtp google, i always get this error
    – Shandy Kurnia
    Nov 19 at 7:34


















  • Try removing ssl:// part from host parameter perhaps and see if it works (also uncomment smtp_crypto then)
    – p0358
    Nov 18 at 21:32












  • uncomment smtp crypto and run in terminal setsebool httpd_can_network_connect=1
    – user969068
    Nov 18 at 22:37












  • i've tried uncomment smtp crypto and remove ssl:// still got same error message "fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)"
    – Shandy Kurnia
    Nov 19 at 1:10










  • Possible duplicate of fsockopen(): unable to connect to ssl://smtp.gmail.com:465
    – Twinkle
    Nov 19 at 4:33










  • what do you mean by duplicate ? If im using another smtp server, it works. but if im using smtp google, i always get this error
    – Shandy Kurnia
    Nov 19 at 7:34
















Try removing ssl:// part from host parameter perhaps and see if it works (also uncomment smtp_crypto then)
– p0358
Nov 18 at 21:32






Try removing ssl:// part from host parameter perhaps and see if it works (also uncomment smtp_crypto then)
– p0358
Nov 18 at 21:32














uncomment smtp crypto and run in terminal setsebool httpd_can_network_connect=1
– user969068
Nov 18 at 22:37






uncomment smtp crypto and run in terminal setsebool httpd_can_network_connect=1
– user969068
Nov 18 at 22:37














i've tried uncomment smtp crypto and remove ssl:// still got same error message "fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)"
– Shandy Kurnia
Nov 19 at 1:10




i've tried uncomment smtp crypto and remove ssl:// still got same error message "fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)"
– Shandy Kurnia
Nov 19 at 1:10












Possible duplicate of fsockopen(): unable to connect to ssl://smtp.gmail.com:465
– Twinkle
Nov 19 at 4:33




Possible duplicate of fsockopen(): unable to connect to ssl://smtp.gmail.com:465
– Twinkle
Nov 19 at 4:33












what do you mean by duplicate ? If im using another smtp server, it works. but if im using smtp google, i always get this error
– Shandy Kurnia
Nov 19 at 7:34




what do you mean by duplicate ? If im using another smtp server, it works. but if im using smtp google, i always get this error
– Shandy Kurnia
Nov 19 at 7:34












2 Answers
2






active

oldest

votes

















up vote
0
down vote













use sendinblue email provider, it's very easy to implement and it can track emails properly as well as free also.






share|improve this answer





















  • sendinblue.com
    – Mac Rathod
    Nov 19 at 6:52










  • hmm i am planning using ci default email library
    – Shandy Kurnia
    Nov 19 at 16:06


















up vote
0
down vote













Check LESS SECURE APPSon your google account. By turning IT on, IT should work!
LESS SECURE APPS






share|improve this answer





















  • already done that, but still no luck
    – Shandy Kurnia
    Nov 19 at 16:04











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53365448%2fcodeigniter-unable-to-send-email-via-smtp-google-always-got-connection-refused%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













use sendinblue email provider, it's very easy to implement and it can track emails properly as well as free also.






share|improve this answer





















  • sendinblue.com
    – Mac Rathod
    Nov 19 at 6:52










  • hmm i am planning using ci default email library
    – Shandy Kurnia
    Nov 19 at 16:06















up vote
0
down vote













use sendinblue email provider, it's very easy to implement and it can track emails properly as well as free also.






share|improve this answer





















  • sendinblue.com
    – Mac Rathod
    Nov 19 at 6:52










  • hmm i am planning using ci default email library
    – Shandy Kurnia
    Nov 19 at 16:06













up vote
0
down vote










up vote
0
down vote









use sendinblue email provider, it's very easy to implement and it can track emails properly as well as free also.






share|improve this answer












use sendinblue email provider, it's very easy to implement and it can track emails properly as well as free also.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 6:51









Mac Rathod

215




215












  • sendinblue.com
    – Mac Rathod
    Nov 19 at 6:52










  • hmm i am planning using ci default email library
    – Shandy Kurnia
    Nov 19 at 16:06


















  • sendinblue.com
    – Mac Rathod
    Nov 19 at 6:52










  • hmm i am planning using ci default email library
    – Shandy Kurnia
    Nov 19 at 16:06
















sendinblue.com
– Mac Rathod
Nov 19 at 6:52




sendinblue.com
– Mac Rathod
Nov 19 at 6:52












hmm i am planning using ci default email library
– Shandy Kurnia
Nov 19 at 16:06




hmm i am planning using ci default email library
– Shandy Kurnia
Nov 19 at 16:06












up vote
0
down vote













Check LESS SECURE APPSon your google account. By turning IT on, IT should work!
LESS SECURE APPS






share|improve this answer





















  • already done that, but still no luck
    – Shandy Kurnia
    Nov 19 at 16:04















up vote
0
down vote













Check LESS SECURE APPSon your google account. By turning IT on, IT should work!
LESS SECURE APPS






share|improve this answer





















  • already done that, but still no luck
    – Shandy Kurnia
    Nov 19 at 16:04













up vote
0
down vote










up vote
0
down vote









Check LESS SECURE APPSon your google account. By turning IT on, IT should work!
LESS SECURE APPS






share|improve this answer












Check LESS SECURE APPSon your google account. By turning IT on, IT should work!
LESS SECURE APPS







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 6:59









KayaP

184




184












  • already done that, but still no luck
    – Shandy Kurnia
    Nov 19 at 16:04


















  • already done that, but still no luck
    – Shandy Kurnia
    Nov 19 at 16:04
















already done that, but still no luck
– Shandy Kurnia
Nov 19 at 16:04




already done that, but still no luck
– Shandy Kurnia
Nov 19 at 16:04


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53365448%2fcodeigniter-unable-to-send-email-via-smtp-google-always-got-connection-refused%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin