Part of the EllisLab Network
   
2 of 3
2
Gmail SMTP using SSL/TLS
Posted: 15 July 2009 05:39 PM   [ Ignore ]   [ # 16 ]  
Summer Student
Avatar
Total Posts:  16
Joined  07-15-2009

Hey Forum.

I made a custom defined using constants.php file on config/constants.php and then developed a custom smtpconfig function on a controller model to suit the smtp email configuration and the use on a send emailtest function on a controller, please visit my weblog to view the solution:


http://www.carlos-alcala.com/?p=84

Just for the note, I have found that PASSING an string array from config/email.php to the library email constructor (load library) has the bug like the initialize on the SMTP_AUTH so the Gmail test nevers authenticates, I have found after several hours of dev/test.

I hope you like this solution, using gmail and it works fine !!


PS. For Windows XAMP users: uncomment the line extension=php_openssl.dll on the php.ini to work with SSL

 Signature 


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning…

Profile
 
 
Posted: 29 July 2009 05:26 AM   [ Ignore ]   [ # 17 ]  
Summer Student
Total Posts:  10
Joined  07-29-2009

hi.I worked out the code you gave..It shows that “your email is sent” ..but it is not actually sending out the mail..
here the code

<?php

class Test_email extends Controller
{
  function Test_email()
  {
      // load controller parent
      parent::Controller();
      $this->load->library(‘email’);
  }
  function sendEmail()
  {
     

     
      $config = Array(
  ‘protocol’ => ‘smtp’,
  ‘smtp_host’ => ‘ssl://smtp.googlemail.com’,
  ‘smtp_port’ => 465,
  ‘smtp_user’ => ‘name@domain.com’,
  ‘smtp_pass’ => ‘pwd’,
                );
$this->load->library(‘email’, $config);
$this->email->set_newline(”\r\n”);

$this->email->from(‘smithas@qburst.com’, ‘Smitha’);
$this->email->to(‘smithas@qburst.com’);

$this->email->subject(’ CodeIgniter Rocks ‘);
$this->email->message(‘Hello World’);


if (!$this->email->send())
  show_error($this->email->print_debugger());
else
  echo ‘Your e-mail has been sent!’;
       

  }
}

why is this happening?I had openssl enabled..but still the same problem

Profile
 
 
Posted: 01 August 2009 11:09 PM   [ Ignore ]   [ # 18 ]  
Summer Student
Avatar
Total Posts:  16
Joined  07-15-2009

1. I have made the configuration usign constants with DEFINE for ONE SIMPLE REASON, the email library has a bug using an ARRAY CONFIGURATION LOAD LIKE IN YOUR CODE, I have made it that way also with NO SUCCESS, and it seems a problem on the email library constructor usign it that way, so please FOLLOW THE EXAMPLE EXACTLY.

2. Check the port 465 is open on firewall.

3. The show_errors is not showing anything?

4. Are you using a correct Gmail account and password? because you posted a code taht seems a little different from my code.

5. Please follow the code correctly using de DEFINE on the constants.php on my website and then post your results.

6. Please try www.getfirebug.com to verify any errors.

Hope you can get work, this seems a missunderstood problem on your code.

Sincerely,

Carlos

 Signature 


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning…

Profile
 
 
Posted: 03 August 2009 12:11 AM   [ Ignore ]   [ # 19 ]  
Summer Student
Total Posts:  10
Joined  07-29-2009

thank you.. can u please post me your code?
465 is open.
and email address i gave i s valid one..

Profile
 
 
Posted: 23 August 2009 11:02 PM   [ Ignore ]   [ # 20 ]  
Grad Student
Avatar
Rank
Total Posts:  43
Joined  08-06-2009

This may or may not be the right place to post this. But I will anyway.

I have always thought running your own mail server is a pain, and I always thought using Gmail to send email for your site was only ok for small sites.

I recently discovered this company http://www.sendgrid.com and have been very happy with them so far.

 Signature 

—-
Spicer Matthews
Cloudmanic Labs. LLC
http://www.cloudmanic.com

Profile
 
 
Posted: 22 September 2009 12:38 PM   [ Ignore ]   [ # 21 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  107
Joined  05-19-2007

Thank you SO MUCH for this! Fixed an issue I’ve been having for months.

Profile
 
 
Posted: 22 September 2009 12:43 PM   [ Ignore ]   [ # 22 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  804
Joined  06-10-2009

Great post/tutorial, thanks for posting it - might come in handy some day smile

 Signature 

CreativeHalls Web Design and Printing
A few of my projects:
OurGulfCoast Property Management and Vacation Rental (ASP/.NET)
BukuBux - Money Saving Coupons and Gift Certificates (CodeIgniter, LAMP/MySQL)
Rentals800.com - Find a place to rent (CodeIgniter, LAMP/MySQL)
bdh (dot) hall (at) gmail (dotcom)

Profile
 
 
Posted: 27 January 2010 02:41 AM   [ Ignore ]   [ # 23 ]  
Lab Assistant
RankRank
Total Posts:  101
Joined  01-24-2010

good job wrs!!
it works! grin

 Signature 

-the Beginner-

Profile
 
 
Posted: 26 April 2010 04:47 AM   [ Ignore ]   [ # 24 ]  
Summer Student
Total Posts:  28
Joined  10-01-2009

hi all,

im using almost similar code but mine is not working.. im testing it on my real server.here is my code:

<?php

class Test2 extends Controller{
 
  function __construct()
  {
      parent::Controller();
  }
 
  function index()
  {
  $data[‘pagetitle’] = ‘Account Activation’;
  $email = $this->load->view(‘test1’,$data,TRUE);
     
  $config = Array(
  ‘protocol’ => ‘smtp’,
  ‘smtp_host’ => ‘ssl://smtp.googlemail.com’,
  ‘smtp_port’ => 465,
  ‘smtp_user’ => ‘mygmail@gmail.com’,
  ‘smtp_pass’ => ‘mypasswordhere’,
  ‘mailtype’ => ‘html’,
  ‘wordwrap’ => TRUE
  );
  $this->load->library(‘email’, $config);
  $this->email->set_newline(”\r\n”);
 
  $this->email->from(‘mygmail@gmail.com’, ‘farah’);
  $this->email->to(‘usermail@yahoo.com’);
 
  $this->email->subject(’ Testing testing testing….’);
  #$this->email->message(‘Welcome!’);
  $this->email->message($email);
 
  if (!$this->email->send()):
      show_error($this->email->print_debugger());
  else:
 
      echo ‘Your e-mail has been sent!’;
  endif;
  }

?>


i already set my pop3 setting in gmail.but stl got the error.pls someone help me~

fsockopen() [function.fsockopen]: unable to connect to smtp.googlemail.com:465 (Connection timed out)

Profile
 
 
Posted: 26 April 2010 04:54 AM   [ Ignore ]   [ # 25 ]  
Summer Student
Total Posts:  28
Joined  10-01-2009

how to check the openSSL is enabled..

Profile
 
 
Posted: 14 June 2010 09:35 AM   [ Ignore ]   [ # 26 ]  
Summer Student
Total Posts:  2
Joined  06-14-2010

Thanks a lot!
It’s really a very helpful post!
It solves the problem which i’m working on!
Thousand thanks!

Profile
 
 
Posted: 15 September 2010 04:48 PM   [ Ignore ]   [ # 27 ]  
Summer Student
Total Posts:  19
Joined  11-15-2007

This was very helpful, and much better than replacing the Email.php library with Swiftmailer, thank you!

Profile
 
 
Posted: 22 October 2010 11:29 PM   [ Ignore ]   [ # 28 ]  
Summer Student
Total Posts:  2
Joined  10-22-2010

Thank you for sharing the codes. I did the same thing and I got some errors, I found in this line, thanks for sharing this correct code.

$this->load->library(‘email’, $config);


Bob M.

 Signature 

Bob Morton
Fap Turbo review writer

Profile
 
 
Posted: 19 March 2011 07:03 AM   [ Ignore ]   [ # 29 ]  
Summer Student
Total Posts:  1
Joined  03-05-2011
miss_amylee - 26 April 2010 08:54 AM

how to check the openSSL is enabled..

enable SSL in your PHP config. Load up php.ini and find a line with the following:

;extension=php_openssl.dll

Profile
 
 
Posted: 05 April 2011 01:42 PM   [ Ignore ]   [ # 30 ]  
Summer Student
Total Posts:  1
Joined  04-05-2011

VALID FOR CodeIgniter 2:

$this->load->library('email');
            
$config['protocol'"smtp";
$config['smtp_host'"ssl://smtp.googlemail.com";
$config['smtp_port'"465";
$config['smtp_user'"your_gmail_user@gmail.com";//also valid for Google Apps Accounts
$config['smtp_pass'"your_gmail_pass";
$config['charset'"utf-8";
$config['mailtype'"html";
$config['newline'"\r\n";

$this->email->initialize($config);        
        
$this->email->from('form@emailtodomain.com''YOUR_NAME');
$list = array('AA@todomain.com'BB@todomain.com',CC@todomain.com','DD@todomain.com');
$this->email->to($list);
$this->email->subject('TESTING GMAIL');
$this->email->message('<h1>TEXT MSG<h1>'); //Your cool html5 ;P
$this->email->set_alt_message(strip_tags('<h1>TEXT MSG<h1>')); //Only text
        
if ( ! $this->email->send())
{
show_error
($this->email->print_debugger());
else {
echo('DONE');        

Previous: $this->load->library(‘email’, $config_array), and so on hangs & does not work on codeigniter 2

cheers!

Profile
 
 
   
2 of 3
2