How to Setup an SMTP Connection in Moodle?
Messages sent from Moodle can be sent using an SMTP server connection via the PHP mail function.
The PHP mail function on the server may occasionally be turned off in order to protect your website from spam emails coming through hacked websites. You may set up the email to connect to an SMTP server in order to fix this problem. To verify the sender email address, the SMTP server will establish a connection using the login credentials. As a result, the email will be accepted as authenticated by the email address server on the receiving end. An SMTP connection is stable because certain email servers do not allow unsanctioned emails to pass through them.
Steps to Configure SMTP Settings in Moodle
Log into your Moodle dashboard.
In the Settings section, go to Site administration -> Server -> Email -> Outgoing mail configuration.

Go to the Outgoing mail configuration page and configure SMTP settings. Moodle uses the PHP mail function by default to send emails. If the administrator wants to send the email to a specific SMTP server such as Yahoo or Gmail, you can adjust the SMTP configuration settings to enable the use of a different server.

In this post, we will use a Gmail email address for the SMTP settings. You need to configure the below email fields for the mail to work. Check below the example of a generic setup of Gmail SMTP:
SMTP Settings | Description |
---|---|
SMTP hosts | The SMTP host is the server to which the email address gets connected. |
SMTP security | SMTP security will decide whether to encrypt the outgoing email data or not. The SSL setting must be exactly similar to the connection used for the SMTP Host name. |
SMTP username | It is the full email address for the email account. Most email service providers will need the complete email address for the username. |
SMTP password | It is the password for the specific email address that is you are setting up. |
SMTP session limit | It helps to prevent spam coming from the same session on the server. If you limit to 1, you will need to create a new session in order for an email to be set. |
No-reply address | It displays in the return email address. It prevents the email address from being replied to by the recipient. |
Character set | It enables you to change the Character set to UTF-8, EUC-JP, GB18030, GB2312, ISO-2022-JP, ISO-8859-1, or SHIFT-JIS. |
Allow user to select character set | It allows users to change the Character set. |
It allows users to change the Character set. | It sets the character type used for Newline characters. |
After you fill the correct information, click on Save changes. Now the messages that you send via Moodle will get delivered to the Gmail server as an authenticated user.
In this way, you can setup an SMTP connection in Moodle.