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

[eluser]futo[/eluser]
[quote author="dsloan" date="1255893123"]I had problems with this initially and got around it by loading the parameters into an array, then initialising the library using the array.

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

// Set to, from, message, etc.
        
$result = $this->email->send();
[/quote]

This helped me 2 ! ... Smile ... Now there is a totally different error I'll analyze know ... Smile

Just REMOVING THE FILE "email.php" (or renaming it) in the config folder in CodeIgniter MAKES THE DIFFERENCE.

EDIT:
AND !!! ... then I had to install sendmail (Linux/debian: sudo apt-get install sendmail) because PHP - efter correcting the above error - still came up with "Unable to send email using PHP mail()" ... - Now I've received the send mail. It works. Smile

The solution works without ssl. - My method in a controller looks like this (works!):
Code:
public function dummymail()
{
  
  $config = array(
      'protocol' => 'smtp',
      'smtp_host' => 'mail.provider.net',
      'smtp_port' => 25,
      'smtp_user' => 'WRITE_YOUR_EMAIL_HERE',
      'smtp_pass' => 'WRITE_YOUR_PASSWORD_HERE',
      'charset' => 'utf-8',
      'mailtype' => 'html'
      );
  $this->load->library('email',$config);
  
  $this->email->set_newline("\r\n");
  
  $this->email->from('WRITE_YOUR_EMAIL_HERE', 'Your name');
  $this->email->to('WRITE_RECIPIENT_EMAIL_HERE');

  $this->email->subject('Email Test');
  $this->email->message('Testing at home the email class of CodeIgniter.');

  if($this->email->send()) {
   echo 'Your email was sent.';
  } else {
   show_error($this->email->print_debugger());
  }
}

Later I'll see if I can get it to work with ssl.




Theme © iAndrew 2016 - Forum software by © MyBB