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

Email setup gmail: Difference between revisions

From MoodleDocs
(s)
 
 
(19 intermediate revisions by 8 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.
{{Update}}
Google's mail servers can be set up as the SMTP server for Moodle, although in many cases may not be suitable for a production system (see first heading below).


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


I was able to get Gmail working under these conditions by doing the following:
== Is Google mail suitable for your requirements? ==
Google mail has a couple of limitations which make it unsuitable for many Moodle installs, please check the following two points before continuing.
# '''No support for multiple "From" addresses.''' When sending emails, Moodle attempts to send them "From" the email address of the user writing the message, this allows the recipient to reply directly to the sender via email. Google, both in their Gmail and Apps for Education product do not allow this - so any emails sent from the system will be from the account you use to authenticate on the SMTP server. To make things more confusing, the name will be the recipients, but the email address will be the SMTP account's email address, for example: "Dr Fred Bloggs" <moodlemail@mycollege.edu>. If you wanted to use Gmail's SMTP regardless, you would be advised to use a dedicated account for the purpose, and have an auto response so that messages to the address bounce back with an instruction to click on the link in the email and reply through Moodle.
# '''Daily limit of 500 sent messages.''' There is a daily limit on any one google account of [http://googlesystem.blogspot.com/2008/06/gmails-limitations-for-sending-messages.html 500 individual email messages, or 2000 recipients across all emails]. Your account can get blocked if you go over this on a regular basis. If you have more than 500 users, it will only take one message to the front page news forum to exceed this quota.


In the Email section for smtp host I used: smtp.gmail.com
== Email settings ==
My @theseventhsungame.net email (Which again we use Gmail domains..)
Location: ''Settings > Site administration > Plugins > Message outputs > Email''
The above email's password.


'''SMTP hosts:''' smtp.gmail.com:465  ''NOTE: Leave out the port (:465) in 1.9.2 or lower''


I then opened /lib/phpmailer/ and modified the following files:
'''SMTP username:''' Your email address @gmail.com or your own domain if using Google Apps


class.phpmailer.php  
'''SMTP password:''' password for the above email account
 
== Code Modification ==
In your Moodle site go to <tt>/lib/phpmailer/</tt> 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;
 
Note: It appears that you can simply enter your host as ssl://smtp.gmail.com:465 to avoid the need for code changes.
 
== 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  
around line 162  
*Change <tt>var $Port = 25;</tt> to <tt>var $Port = 465;</tt>


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


class.phpmailer.smtp
== Tips and tricks ==
around line 30


I changed var $SMTP_PORT = 25; to 465
* Some sites may need the additional step of un-commenting the '''php_openssl.dll''' extension in <tt>php.ini</tt>.


In the class.phpmailer.smtp file
===Google education edition with 1.9.9===
around line 83
When using Google Education Edition with 1.99


DIRECTLY after the Fucntion header, so the next line after the {
The latest php mailer is paramont. If someschool.edu email at google is not accepting mails from the moodle as valid mails you need to create an SPF record at your host, allowing mail from the Central Mail server, Google and the local server which satisified Google's validation desires.
I added:
$host='ssl://' . $host;


I am now sending mail using the GMAIL feature.
@ 14400 IN TXT "v=spf1 ip4:174.121.161.XXX
include:aspmx.googlemail.com mx:c1.hostname.com ~all"


http://www.theseventhsungame.net
This bit is server side more than moodle so if you are on managed or shared hosting the server admin will have to do the record (try submitting a request to have the record added with full details of how and why to do so) then follow the previous the directions in this record.
http://www.theseventhsungame.net/tssuniversity


Hope that helps someone =)
== See also==


Sincerely,
*Email settings in [[Messaging settings]]
Chel Ramsey
admin@theseventhsungame.net


*Blog reference in [https://carlos4web.wordpress.com/2009/06/04/configurando-emails-com-ssl-no-moodle/ link Setting SSL mails in Moodle 1.9.x]


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.
[[ja:GmailでのEメール設定]]

Latest revision as of 13:41, 31 May 2012

This page requires updating for Moodle 2.2. Please do so and remove this template when finished.


Google's mail servers can be set up as the SMTP server for Moodle, although in many cases may not be suitable for a production system (see first heading below).

Setting it up will require a hack to the code.

Is Google mail suitable for your requirements?

Google mail has a couple of limitations which make it unsuitable for many Moodle installs, please check the following two points before continuing.

  1. No support for multiple "From" addresses. When sending emails, Moodle attempts to send them "From" the email address of the user writing the message, this allows the recipient to reply directly to the sender via email. Google, both in their Gmail and Apps for Education product do not allow this - so any emails sent from the system will be from the account you use to authenticate on the SMTP server. To make things more confusing, the name will be the recipients, but the email address will be the SMTP account's email address, for example: "Dr Fred Bloggs" <moodlemail@mycollege.edu>. If you wanted to use Gmail's SMTP regardless, you would be advised to use a dedicated account for the purpose, and have an auto response so that messages to the address bounce back with an instruction to click on the link in the email and reply through Moodle.
  2. Daily limit of 500 sent messages. There is a daily limit on any one google account of 500 individual email messages, or 2000 recipients across all emails. Your account can get blocked if you go over this on a regular basis. If you have more than 500 users, it will only take one message to the front page news forum to exceed this quota.

Email settings

Location: Settings > Site administration > Plugins > Message outputs > 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;

Note: It appears that you can simply enter your host as ssl://smtp.gmail.com:465 to avoid the need for code changes.

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.

Google education edition with 1.9.9

When using Google Education Edition with 1.99

The latest php mailer is paramont. If someschool.edu email at google is not accepting mails from the moodle as valid mails you need to create an SPF record at your host, allowing mail from the Central Mail server, Google and the local server which satisified Google's validation desires.

@ 14400 IN TXT "v=spf1 ip4:174.121.161.XXX include:aspmx.googlemail.com mx:c1.hostname.com ~all"

This bit is server side more than moodle so if you are on managed or shared hosting the server admin will have to do the record (try submitting a request to have the record added with full details of how and why to do so) then follow the previous the directions in this record.

See also