Email Configuration

Email Configuration

Email is a vital component of Moodle, used for notifications, forum post subscriptions, password resets, enrolment confirmations, and many other communications. Properly configuring email ensures reliable delivery of messages from your Moodle site.

Outgoing Mail Configuration

Configure SMTP settings at Site administration > Server > Outgoing mail configuration:

SMTP Settings

  • SMTP hosts: The SMTP server address. Include the port number separated by a colon (e.g., smtp.example.com:587). For SSL connections, use port 465; for STARTTLS, use port 587. You can specify multiple servers separated by semicolons as fallbacks.
  • SMTP security: Choose the encryption protocol:
    • None: No encryption (not recommended)
    • SSL: Implicit SSL/TLS on port 465
    • TLS: STARTTLS on port 587 (recommended)
  • SMTP Auth Type: Authentication method — LOGIN, PLAIN, CRAM-MD5, or NTLM
  • SMTP username: Username for SMTP authentication
  • SMTP password: Password for SMTP authentication

Email Addresses

  • No-reply address: The address used for emails that should not be replied to (e.g., noreply@yourmoodle.example.com). This is used for notifications and system messages.
  • Support email: The email address displayed for user support queries
  • Allowed email domains: Restrict email addresses to specific domains during self-registration
  • Denied email domains: Block registrations from specific email domains (e.g., disposable email services)

Email Headers and Formatting

  • Email character set: Default is UTF-8, which supports all languages
  • Always send HTML email: When enabled, sends all emails in HTML format
  • Newline characters in mail: Choose between LF and CRLF line endings (try LF first; switch to CRLF if emails have formatting issues)
  • Email via information: Adds an "on behalf of" header to emails sent from Moodle on behalf of users (e.g., forum posts)

Testing Email Configuration

After configuring SMTP settings, test email delivery:

  1. Navigate to Site administration > Server > Outgoing mail configuration
  2. Click the Test outgoing mail configuration link at the bottom of the page
  3. Enter a recipient email address and send a test message
  4. Check for successful delivery and review any error messages

You can also test email from the command line:

php admin/cli/test_email.php --to=test@example.com --subject="Test" --body="Moodle email test"

Common Email Issues

Emails Not Being Sent

  • Verify SMTP settings are correct (host, port, credentials)
  • Check that cron is running (many emails are queued and sent via cron)
  • Check the mdl_task_adhoc table for queued email tasks
  • Review PHP mail logs and SMTP server logs for errors
  • Ensure the server can reach the SMTP host (test with telnet smtp.example.com 587)

Emails Going to Spam

  • Configure SPF, DKIM, and DMARC records for your domain
  • Ensure the From address matches a valid domain
  • Use a dedicated SMTP service (SendGrid, Amazon SES, Mailgun) for better deliverability
  • Avoid using generic free email services as the From address

Email Throttling

Some SMTP providers limit the number of emails sent per hour/day. Moodle sends many emails (forum subscriptions, notifications), so consider:

  • Using a high-volume email service
  • Adjusting forum digest settings to reduce email volume
  • Configuring email processing frequency in scheduled tasks

User Email Preferences

Users can control their email preferences under Preferences > Notification preferences. They can choose which types of notifications to receive via email, web, or mobile, and set online/offline preferences for each notification type.

Configuring via config.php

For automated deployments or to prevent admin UI changes, set email configuration in config.php:

$CFG->smtphosts = 'smtp.example.com:587';
$CFG->smtpsecure = 'tls';
$CFG->smtpauthtype = 'LOGIN';
$CFG->smtpuser = 'apikey';
$CFG->smtppass = 'SG.xxxxxxxx';
$CFG->noreplyaddress = 'noreply@yourmoodle.example.com';

¿Le ha resultado útil este artículo?

  • Site Administration Overview

    Site Administration Overview The Site administration panel is the central hub for managing all aspec...
  • Server Settings

    Server Settings Moodle provides extensive server configuration options that control how the applicat...
  • Security Settings

    Security Settings Moodle provides a comprehensive set of security settings to protect your site from...
  • Backup Settings

    Backup Settings Moodle provides a built-in course backup system that creates compressed archives of ...
  • Caching

    Caching Moodle uses a sophisticated caching framework called MUC (Moodle Universal Cache) to improve...