Email setup gmail

Revision as of 00:08, 21 November 2008 by Richard Enison (talk | contribs) (Code Modification: grammar corrections)

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 3.2. Up-to-date documentation for the latest stable version of Moodle is probably available here: Email setup gmail.

Google's mail servers can be set up as the SMTP server for Moodle. This reduces or eliminates the need for an email service on a server and is especially useful if Google Apps is used by the institution using Moodle.

This will require a hack to the code.

Email settings

Location: Administration > Server > Email

SMTP hosts: NOTE: Leave out the port (:465) in 1.9.2 or lower

SMTP username: Your email address or your own domain if using Google Apps

SMTP password: password for the above email account

Code Modification

In your Moodle site go to /lib/phpmailer/ and modify the following file:


Around line 83 DIRECTLY after the Connect function header, insert this line immediately after the "{" :

$host = 'ssl://' . $host;

Code Modification (1.9.2 or lower)

These two additional modifications need to be made in 1.9.2 or lower as the SMTP hosts setting above will not allow the port to be included.


around line 162

  • Change var $Port = 25; to var $Port = 465;


around line 30

  • Change var $SMTP_PORT = 25; to var $SMTP_PORT = 465;

Tips and tricks

  • Some sites may need an additional step to un-comment the php_openssl.dll extension in php.ini.

See also

Email settings