Why I can't send out the email? (CodeIgniter, Apache 2.2.22, PHP 5.4.3)

Why the email can’t send out :rolleyes:

Background :
WAMP2.2 (Apache Version :2.2.22 PHP Version :5.4.3, MySQL Version :5.5.24),
CodeIgniter2.2.0

ApacheConfig
Enable already =>
mod_mime
mod_rewrite
mod_ssl

PHP config
Enable already => php_openssl

SMTP => ssl://smtp.gmail.com
smtp_port => 465

$data['message'] = '<p>The email has successfully been sent!!</p>';
			
			// load the email class (i.e. library)
			$emailConfig = array(
				'protocol' => 'smtp',
				'smtp_host' => 'ssl://smtp.googlemail.com',
				'smtp_port' => 465,
				'smtp_user' => 'myEmail@gmail.com',
				'smtp_pass' => 'myPSWD',
				'charset' => 'utf-8',
				'mailtype' => 'html',
				'newline' => '\\r\
',
				'crlf' => '\\r\
'
				);
			$this->load->library('email',$emailConfig);
			$this->email->set_newline('\\r\
');
			$this->email->from('myEmail@gmail.com','myEmailUserName');
			$this->email->to('myEmail@gmail.com');
			$this->email->subject('Message from out form');
			$this->email->message(set_value('message'));

For the ssl_host, use this instead: smtp.gmail.com

“ssl://” is not a valid protocol, and google does not use “googlemail.com” as their SMTP server.

For “protocol”, I’m assuming the value should be “https”, rather than “smtp”. However, the documentation for the library you are using would make this clear. What is the name of the email library that you are using?

Hi Force Flow, thanks for your reply ^ ^
I have tried to change the protocol (in controller, php file) to https, but it’s failure.

The email library I used is the original one including in CodeIgniter already… (i.e. http://ellislab.com/codeigniter/user-guide/libraries/email.html)

I have changed the “smtp_host” in the controller, but showing the error message as below.

*** error showing on the browser/webpage ***
The following SMTP error was encountered:
Failed to send AUTH LOGIN command. Error:
from:
The following SMTP error was encountered:
to:
The following SMTP error was encountered:
data:
The following SMTP error was encountered:

The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Sun, 29 Jun 2014 08:57:56 +0000
From: “myName” <myEmail@gmail.com>
Return-Path: <myEmail@gmail.com>
To: myEmail@gmail.com
Subject: =?utf-8?Q?Message_from_out_form?=
Reply-To: “myEmail@gmail.com” <myEmail@gmail.com>
X-Sender: myEmail@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <53afd51495fc3@gmail.com>
Mime-Version: 1.0

Content-Type: multipart/alternative; boundary=“B_ALT_53afd51495fd2”

This is a multi-part message in MIME format.
Your email application may not support this format.

–B_ALT_53afd51495fd2
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

testing~

–B_ALT_53afd51495fd2
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

testing~

–B_ALT_53afd51495fd2–

*** site.php (in controller, CodeIgniter2.0) ***

			$data['message'] = '<p>The email has successfully been sent!!</p>';
			
			//load the email class (i.e. library)
			$emailConfig = array(
				'protocol' => 'smtp',
				'smtp_host' => 'smtp.gmail.com',
				'smtp_port' => 465,
				'smtp_user' => 'myEmail@gmail.com',
				'smtp_pass' => 'myPSWD',
				'charset' => 'utf-8',
				'mailtype' => 'html',
				'newline' => '\\r\
',
				'crlf' => '\\r\
'
				);

			$this->load->library('email',$emailConfig);
			// $this->load->library('email');
			
			//$this->email->from(set_value('email'),set_value('fullname'));
			$this->email->set_newline('\\r\
');
			$this->email->from('myEmail@gmail.com','myName');
			$this->email->to('myEmail@gmail.com');
			$this->email->subject('Message from out form');
			$this->email->message(set_value('message'));

			if ($this->email->send()) 
			{

				echo 'Your email was sent!!';

			} else {

				echo $this->email->print_debugger();

			}

*** php.ini ***
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = ssl://smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = myEmail@gmail.com

Furthermore, the config file, email.php (c:\wamp\www\…\application\config\email.php) is configured as below

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// $config['useragent']        = 'CodeIgniter';
$config['protocol']         = 'smtp';        
// $config['mailpath']         = '';
// $config['smtp_crypto']      = 'ssl';
$config['smtp_host']        = 'smtp.gmail.com';
$config['smtp_user']        = 'myEmail@gmail.com';
$config['smtp_pass']        = 'myPSWD';
$config['smtp_port']        = 465;
$config['smtp_timeout']     = 5;
// $config['wordwrap']         = TRUE;
// $config['wrapchars']        = 76;
$config['mailtype']         = 'html';
$config['charset']          = 'utf-8';
// $config['validate']         = FALSE;
// $config['priority']         = 3;
$config['crlf']             = '\\r\
';
$config['newline']          = '\\r\
';
// $config['bcc_batch_mode']   = FALSE;
// $config['bcc_batch_size']   = 200;

/* End of file email.php */
/* Location: ./application/config/email.php */