This is a test site. Any changes will be lost!

Email setup gmail: Difference between revisions

From MoodleDocs
s
 
Tips and tricks: clarification
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Hello. I run Moodle and my project uses the Gmail 'domains' service where we use Gmail as our email processor. IE: We have no email service on our server, we use Googles.
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 [http://www.google.com/apps/ Google Apps] is used by the institution using Moodle.


We run Moodle to train new developers/staff and so we needed the emails from the courses and Ask a Question type module.
This will require a hack to the code.


I was able to get Gmail working under these conditions by doing the following:
== [[Email settings]] ==
Location: ''Administration > Server > [[Email settings|Email]]''


In the Email section for smtp host I used: smtp.gmail.com
'''SMTP hosts:''' smtp.gmail.com:465  ''NOTE: Leave out the port (:465) in 1.9.2 or lower''
My @theseventhsungame.net email (Which again we use Gmail domains..)
The above email's password.


'''SMTP username:''' Your email address @gmail.com or your own domain if using Google Apps


I then opened /lib/phpmailer/ and modified the following files:
'''SMTP password:''' password for the above email account


class.phpmailer.php
== Code Modification ==
around line 162
In your Moodle site go to <tt>/lib/phpmailer/</tt> and modify the following file:


I changed var$Port =25; to 465
=== class.smtp.php ===
Around line 83 DIRECTLY after the '''Connect''' function header, insert this line immediately after the "{" :
$host = 'ssl://' . $host;


class.phpmailer.smtp
== Code Modification (1.9.2 or lower) ==
around line 30
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.


I changed var $SMTP_PORT = 25; to 465
=== class.phpmailer.php ===
around line 162
*Change <tt>var $Port = 25;</tt> to <tt>var $Port = 465;</tt>


In the class.phpmailer.smtp file
=== class.smtp.php ===
around line 83
around line 30
 
*Change <tt>var $SMTP_PORT = 25;</tt> to <tt>var $SMTP_PORT = 465;</tt>
DIRECTLY after the Fucntion header, so the next line after the {
I added:
$host='ssl://' . $host;  
 
I am now sending mail using the GMAIL feature.
 
http://www.theseventhsungame.net
http://www.theseventhsungame.net/tssuniversity
 
Hope that helps someone =)


Sincerely,
== Tips and tricks ==
Chel Ramsey
admin@theseventhsungame.net


* Some sites may need the additional step of un-commenting the '''php_openssl.dll''' extension in <tt>php.ini</tt>.


PS an additional step you may or may not need to take is to Un-comment the php_openssl.dll extension in php.ini I did not have to do this.
== See also==
[[Email settings]]

Latest revision as of 00:10, 21 November 2008

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: smtp.gmail.com:465 NOTE: Leave out the port (:465) in 1.9.2 or lower

SMTP username: Your email address @gmail.com 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:

class.smtp.php

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.

class.phpmailer.php

around line 162

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

class.smtp.php

around line 30

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

Tips and tricks

  • Some sites may need the additional step of un-commenting the php_openssl.dll extension in php.ini.

See also

Email settings