Monday, December 07, 2009

GMAIL SMTP with Joomla

Well after spending forever on trying to figure out how I could use gmail or in my case google aps on my joomla account, I will spread this information to the community!

This is a very simple "hack" to the code that will allow you to send email with google's smtp server:

You will have to locate the file that will be changed based on which version of Joomla! you have.

phpmailer.php file in 1.5

on line 537 or close to it

The original code would be something like:
if(strstr($hosts[$index], ":"))
list($host, $port) = explode(":", $hosts[$index]);
else
{
$host = $hosts[$index];
$port = $this->Port;
}

You must change this to:

if (preg_match('#(([a-z]+://)?[^:]+):(\d+)#i', $hosts[$index], $match))
{
$host = $match[1];
$port = $match[3];
}
else
{
$host = $hosts[$index];
$port = $this->Port;
}

and ofcourse you have to enter the SMTP details under Global Configurations page after login to Joomla Administration page.

No comments: