CodeIgniter + Email + SMTP Custom Config to Gmail Working
I was trying to make use of the email library on codeigniter, and found some issues on the Gmail config and authentication errors, then after making my own I have made a custom configuration that works fine.
1. Create this CONSTANTS on config/constanst.php
define('MAIL_PROT', 'smtp');
define('SITE_ADMIN', 'Webmaster');
define('SITE_EMAIL', 'gmail.user@gmail.com');
define('SMTP_HOST', 'ssl://smtp.googlemail.com');
define('SMTP_USER', 'gmail.user@gmail.com');
define('SMTP_PASS', 'somepassword');
define('SMTP_PORT', 465);
define('MAIL_TYPE', 'html');
define('MAIL_CHARSET', 'utf-8');
2. Then create a smtp config function on a email_model for example:
function smtpconfig()
{
$config = array();
//$config = $this->config->item('email');
$config = Array(
'protocol' => MAIL_PROT,
'smtp_host' => SMTP_HOST,
'smtp_port' => SMTP_PORT,
'smtp_user' => SMTP_USER,
'smtp_pass' => SMTP_PASS,
'smtp_timeout' => 30,
'mailtype' => MAIL_TYPE
);
//var_dump($config);
$this->load->library('email', $config);
$this->email->clear();
$this->email->set_newline("\r\n");
}
3. Finally we can use BOTH in a test function like:
function emailtest()
{
$this->smtpconfig();
$this->email->from(SITE_EMAIL, SITE_ADMIN);
$this->email->to('receiver.user@gmail.com');
$this->email->subject('CodeIgniter & Gmail Rules !! ');
$this->email->message('Hello Gmail World');
if (!$this->email->send())
show_error($this->email->print_debugger());
else
echo 'Your e-mail has been sent!';
}
I hope this would be useful.
Thanks for your feedback,
Carlos
30 HTML Best Practices for Beginners
Thanks to Jeffrey Way for this great article, I just want to share to the world (and thanks Peter Hanson for this also)...
30 HTML Best Practices for Beginners
I hope it would be useful for all the Web  developers.
Carlos
Web Developer Tools
With so many browser out there in the wild, working as a Web Developer certainly is not an easy job these days. Thankfully, over the last years, decent tools have been developed by bright people that make developing and debugging of code easier for the developer. But sometimes, it is not easy to keep track which tools are at a Developer’s disposal (and which are actually usable). The following article seeks to list the best tools available and quickly describing how to activate/install/use them.
Thanks to KlausKomenda.com
http://www.klauskomenda.com/archives/2008/02/16/collection-of-web-developer-tools-per-browser/
