CodeIgniter Forums
Sending email with gmail smtp with codeigniter email library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Sending email with gmail smtp with codeigniter email library (/showthread.php?tid=51890)



Sending email with gmail smtp with codeigniter email library - El Forum - 05-22-2012

[eluser]naveen27[/eluser]

Code:
class Email extends Controller
{
function __construct()
{
  parent::Controller();
}

function index()
{
$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'my mail',
    'smtp_pass' => 'my password',
    'mailtype'  => 'html',
    'charset'   => 'iso-8859-1'
);
  $this->load->library('email', $config);
$this->email->set_newline("\r\n");
  
  $this->email->from('[email protected]', 'aaa');
  $this->email->to('[email protected]');  
  $this->email->subject('This is an email test');  
  $this->email->message('It is working. Great!');
  $result = $this->email->send();
  echo $this->email->print_debugger();
  
  
}
}
I am getting this error


A Database Error Occurred

Unable to connect to your database server using the provided settings.


Can any one help me how to send the mail using Codeigniter.


Sending email with gmail smtp with codeigniter email library - El Forum - 05-22-2012

[eluser]gRoberts[/eluser]
You are loading the database library without putting in the correct database settings in the /config/database.php file.


Sending email with gmail smtp with codeigniter email library - El Forum - 05-22-2012

[eluser]naveen27[/eluser]
Hi gRoberts,
i change the database settings in the /config/database.php file .Again it showing the another error

like


A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)

Filename: libraries/Email.php

Line Number: 1646

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1812

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789

Can you help me
Thanks in advanced.


Sending email with gmail smtp with codeigniter email library - El Forum - 05-22-2012

[eluser]gRoberts[/eluser]
This means that your PHP instance does not have SSL installed.

You need to speak to your host or server administrator to install it.


Sending email with gmail smtp with codeigniter email library - El Forum - 05-22-2012

[eluser]naveen27[/eluser]
Hi gRoberts,
Can you help me how to install the SSL.

Thanks in advanced.


Sending email with gmail smtp with codeigniter email library - El Forum - 05-23-2012

[eluser]Unknown[/eluser]
The $config array should be

Code:
$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'smtp.gmail.com',
    'smtp_port' => 465,
    'smtp_crypto' => 'ssl',
    'smtp_user' => 'your mail',
    'smtp_pass' => 'your password',
    'mailtype'  => 'html',
    'charset'   => 'iso-8859-1'
);



Sending email with gmail smtp with codeigniter email library - El Forum - 10-24-2013

[eluser]Unknown[/eluser]
To install the SSl:

First see if there is open-ssl extension in your php.ini file if not then put the below code in the ini file in extension part.
extension=php_openssl.dll

Restart the Apache service.

Done Smile