Joomla: Setup Smtp Email Capability Using a Gmail Account

This is to setup email capability in a Joomla project. You can use a Gmail account to act as the smtp server.

Set smtp server settings

In Joomla admin panel go to Site -> Global Configuration -> Server -> Mail Settings and set these parameters:

Mailer - SMTP Server
SMTP - Yes
SMTP Security - SSL
Port - 465 or 587
SMTP Username - your gmail email address
SMTP password - your gmail password
SMTP host:

You now have access to a smtp server to send emails from Joomla.

Sending an email

You can use the following to send a basic email. Will generate a error message if not sent successfully.


//clean functions eliminate risk of script injection 
//attacks from a form submit.
$sender_name = JMailHelper::cleanAddress($sender_name);
$subject = JMailHelper::cleanSubject($subject);
$body = JMailHelper::cleanBody($body)
$mode = true; //true=html, false=plain text
$cc = ''; //cc setting might not work. Try the bcc instead.
$bcc[] = ''; //Is an array of addresses

if (!JUtility::sendMail($sender_email, $sender_name, $recipient,
 $subject, $body, $mode, $cc, $bcc))
	JError::raiseNotice( 500, 'Email failed.' );

The 6th parameter $msgType sets if email body is plain text or html. Default is plain text. If your sending html then set it to true.

Sending attachments

$attach[] = "/path/to/file";
$attach[] = "/path/to/file";
JUtility::sendMail($sender_email, $sender_name, $recipient, 
$subject, $body,false,'','',$attach);

Take a look at the sendMail() API doc here.

Leave a comment


  1. Robert Wilson

    thanks for the post

  2. Does not work, has someone made it work?

  3. It works!!! Thanks a lot :mrgreen:

  4. thankyou it works :)

  5. The following from address failed:
    Error: Mail has not been sent. Please try again later.

    I have set it up as you guys mentioned .If you have any solution pls mail me my mail is …thanks in advance :oops:

  6. Hi There ,
    I Do All config that mentioned on this post
    and actived gmail authentication,
    I do’nt know why it doesn’t work!!!! :sad: :sad: :sad: :sad:

  7. Hi My dear friend

    I’m working in joomla 2.5.X and tested it in joomla 1.5.
    I face this error message “Could not Coneccft to Smtp host!”
    I have tested all config with phpmailer and swiftmailer
    thus, I faced this popular problem on there :
    “Could not Coneccft to Smtp host!”

    It “worthy to say” I trying send email with gmail smtp remote server
    and Now Dosen’t Work!

    What I DO?

    yours sincerly

  8. I have read so many articles or reviews concerning the blogger loovers except this piece of writing is really a nice paragraph,
    keep iit up.

  9. In joomla 1.5 sendmail function bcc mail is not coming.
    pls help me!

  10. Hi admin, i must say you have very interesting articles here.
    Your page should go viral. You need initial traffic boost only.
    How to get it? Search for: Mertiso’s tips go viral