How can I send email from localhost using my gmail account.

#1
[eluser]Arun Joshi[/eluser]
Hi,

How to send email from localhost using gmail account?

#2
[eluser]Arun Joshi[/eluser]
After 20 minutes CI forum searching I got the solution. :coolsmile:

$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'myusername@gmail.com',
'smtp_pass' => 'mypassword',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

$this->email->from('fromuser@anyaccount.com', 'Mr. Test');
$this->email->to('touser@anyaccount.com');

$this->email->subject(' My mail through codeigniter from localhost ');
$this->email->message('Hello World...');


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


Got Solution from this thread
http://ellislab.com/forums/viewthread/84689/

Anyway
Thanks

#3
[eluser]Mike Ryan[/eluser]
You can find some good tutorials on this site ;-)

#4
[eluser]Dam1an[/eluser]
@Arun, glad you got it sorted, but can you please use [ code ] tags in future, reading non formatted code gives me headaches Tongue

#5
[eluser]Arun Joshi[/eluser]
Sure, I will use code window. Thanks Mr.Dam1an.

#6
[eluser]Musaddiq Khan[/eluser]
I have used the following code and it generate some errors.

Code:
$config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://smtp.googlemail.com',
  'smtp_port' => 465,
  'smtp_user' => 'myuser@gmail.com', // change it to yours
  'smtp_pass' => 'mypass', // change it to yours
  'mailtype' => 'html',
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);

      $message = 'Hello this is test message...';
      $this->load->library('email', $config);
      $this->email->set_newline("\r\n");
      $this->email->from('myuser@gmail.com'); // change it to yours
      $this->email->to('mypass@gmail.com');// change it to yours
      $this->email->subject('Resume from JobsBuddy for your Job posting');
      $this->email->message($message);
      if($this->email->send())
     {
      echo 'Email sent.';
     }
     else
    {
     show_error($this->email->print_debugger());
    }

#7
[eluser]CroNiX[/eluser]
it's saying you don't have the SSL protocol installed/enabled on your web server, so CI (or anything php) can't use SSL until you do that.

#8
[eluser]InsiteFX[/eluser]
apache server - httpd.conf
Code:
// remove the pound sign from the beginning.
#LoadModule ssl_module modules/mod_ssl.so

php - php.ini
Code:
// remove the semi-colon from the beginning of it.
;extension=php_openssl.dll

#9
[eluser]CroNiX[/eluser]
Also has to be enabled in the webserver for php to use it.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.