Welcome Guest, Not a member yet? Register   Sign In
Sending email with gmail smtp with codeigniter email library
#1

[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.
#2

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

[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.
#4

[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.
#5

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

Thanks in advanced.
#6

[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'
);
#7

[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




Theme © iAndrew 2016 - Forum software by © MyBB