Moodle outgoing email and bounce handling

Moodle email depends on an SMTP relay, sender authentication on your domain and bounce settings that decide when a bad address stops receiving mail. This page explains how to set each one and what to confirm before rollout.

On this page

Why Moodle email delivery needs planning before go-live

When Moodle email fails, nothing announces it. Course enrolment messages, forum notifications, password resets and account confirmations simply never arrive, and the first sign is usually a learner or administrator asking why. Moodle email covers four separate pieces: outgoing SMTP delivery through a relay, sender authentication (SPF and DKIM) on your domain, bounce handling that decides when a bad address is stopped, and inbound email-to-forum processing. Each one has its own settings, its own failure modes and its own owner, and a plan that treats them as one setting will leave at least one of them unowned on launch day. Name an owner for the SMTP relay and DNS records, an owner for the noreply sender identity, and an owner for bounce and inbound mail before the first learner is enrolled.

Teams usually need this topic at two moments. The first is a new self-hosted Moodle site, where no mail path exists yet and the platform team must connect it to a relay their organization controls. The second is a move away from a shared mail host or a hosted service that handled sending, authentication and bounces without the site team having to think about them. In both cases the old arrangement often hid decisions: who approved the sending domain, which DNS records were already published, and whether anyone was reading bounce reports. Before go-live, confirm with your mail administrator which relay and sending domain Moodle will use, whether your domain already publishes SPF and DKIM records that cover that relay, and where bounce and inbound messages will land. Those answers determine the rest of the configuration work described below.

Outgoing email options and when each fits

This table compares the main outgoing mail choices for a self-hosted Moodle site and the config-dist.php keys that control bounce handling and email-to-forum processing. Read each row as a decision: most sites keep the defaults until a specific delivery or inbound problem makes a setting worth changing.

Choice or settingWhat it controlsWhen it is worth changing
Built-in mail with a local MTAMoodle hands messages to the server's local mail agent for delivery directly from your hostSuits small single-server sites with a stable outbound IP and reverse DNS you control; confirm mailbox provider acceptance first
SMTP relayMoodle sends through a relay host with authentication, and the relay handles outbound deliveryUsually preferred when the hosting network blocks port 25 or when your mail provider requires authenticated submission
Noreply address and sender nameThe From address and display name on system notificationsChange when recipients need a clear sender, when the domain must match your SPF and DKIM records, or when replies must go to a monitored inbox
handlebouncesWhether Moodle processes bounced messages and tracks delivery failures for usersKeep enabled for most sites so repeated failures are handled; disable only if your mail platform already manages bounces and you have confirmed that choice
minbouncesMinimum number of bounces before Moodle treats an address as bouncingRaise on noisy networks where transient failures are common; lower if bad addresses keep receiving mail
bounceratioShare of sent messages that must bounce before the address is flaggedAdjust alongside minbounces so the threshold matches your normal volume; confirm the current meaning in the config-dist.php comments
mailprefixPrefix on the mailbox used for email-to-module (for example, posting to a forum by email)Set only if you enable inbound processing; the value must be exactly four characters, so a value of any other length will not work
Inbound mailbox for email-to-forumA dedicated mailbox polled or piped so replies and posts reach MoodleNeeded only when email-to-module is enabled; plan its SPF, DKIM and access controls separately from outbound mail

How to set up Moodle SMTP, DNS and bounce settings

This sequence takes Moodle from an unconfigured mail path to a verified outgoing relay, authenticated sending domain and tuned bounce handling. Each step ends with a check so the team knows the previous step is working before the next one starts.

  1. Confirm the relay and sending identity with the mail team

    Before touching Moodle, agree with the mail or messaging team which SMTP relay will send for the site, the host, port and encryption mode, the authentication method and credentials, and the exact From address, such as a noreply address on your domain. Ask who owns the relay account and whether it permits sending from that domain. Record these in your change notes. You are done when the mail team has confirmed the relay accepts submissions from the Moodle server's network path and the From address is approved.

  2. Set SMTP options in Moodle admin and config.php

    Enter the agreed host, port, security mode and credentials under the outgoing mail configuration in Moodle's site administration, and set the no-reply address and support address. Keep the password out of the database where your standards require it by storing the SMTP credentials in config.php, which is kept outside the web root and readable only by the web server account. Confirm the file permissions after editing. You are done when the settings save without error and the configuration file loads on the next page request.

  3. Send a test message and confirm delivery

    Use the test outgoing mail configuration tool in Moodle to send a message to a mailbox you control, ideally on a different provider from the sending domain. Check that the message arrives in the inbox, not the spam folder, and inspect its headers to confirm the relay and From address match what you agreed. Also trigger a real Moodle notification, such as a password reset for a test account. You are done when both messages arrive with the expected sender and the relay appears in the delivery path.

  4. Publish SPF and DKIM for the sending domain

    Ask the mail team for the SPF include or IP ranges and the DKIM selector and public key that the relay uses for your domain. Publish these as DNS records through your own DNS provider, and confirm each record with that provider's own tools before relying on it. Your relay documentation sets the exact record format, so follow it rather than a generic example. Send another test message after the records propagate and check the authentication results in the headers. You are done when SPF and DKIM both report pass for the Moodle sender.

  5. Confirm the DMARC policy with the domain owners

    Check whether your domain already publishes a DMARC record, and agree with the domain owners what policy applies to Moodle mail before changing it. Moodle messages should align with the domain used in the From address, so a failing SPF or DKIM result will affect them the same way as other mail. Review the aggregate reports that arrive after the change if your organization receives them. You are done when the policy is written down and the reports, or the decision to defer them, are assigned to a named owner.

  6. Set bounce thresholds in config.php

    Enable bounce handling in config.php using the handlebounces setting, then set minbounces and bounceratio to the values your mail team recommends for your traffic. Moodle uses these to decide when to stop sending to an address after repeated bounces. Keep the mailprefix setting at exactly four characters if you plan to use email-to-forum later, and confirm the value with your inbound mail design before you change it. You are done when the file parses without error and the settings appear as expected in the Moodle admin pages.

  7. Verify bounce handling with a test bounce

    Send a message to a deliberately invalid address on the same domain and let the relay return a bounce to the bounce address your team configured. Check the bounce mailbox or the inbound processing log to confirm Moodle receives and records the bounce against the test account. Repeat until the threshold behavior matches your settings. Document the result and the relay behavior you observed, because relay documentation is the final reference for bounce formats. You are done when a test bounce is recorded and the account reaches the threshold you set.

How bounce thresholds decide when Moodle stops mailing a user

Moodle's bounce handling decides when the platform stops sending mail to an address that keeps failing. The three settings in config.php work as a set: handlebounces switches bounce handling on or off, minbounces sets the minimum number of bounces an address must accumulate before it can be flagged, and bounceratio sets the proportion of bounces to sends that must be reached before the address is flagged. Both conditions have to be met, so a user with a few bounces on a low-volume address is not blocked just because the raw count crossed a line. Bounce counts are kept per address, which means one mailbox with a full quota or a retired account is judged on its own history rather than on the whole site's traffic. Confirm the exact behaviour, including how counts reset, against the Moodle config-dist.php file and the Moodle version you run, because the defaults and handling can change between releases.

The threshold is a trade-off between two failures. If Moodle flags an address too early, a learner or teacher misses course notices, grading alerts or enrolment messages that a temporary fault would have delivered a day later. If it flags too late, the platform keeps sending to dead addresses, mailbox providers see a high bounce rate from your sending domain, and legitimate mail starts landing in spam folders or being refused. Neither failure shows up in a single test, so the numbers need to come from your own data: how often addresses bounce in a normal term, and how long your mail provider takes to report a permanent failure. Ask the mail team what bounce rate their provider tolerates and which bounce types they want treated as permanent.

Agree the three values with the mail team before go-live, and write down who owns changes to them. Then test with a controlled set of addresses: a mailbox that rejects mail, a full mailbox if you can create one, and a valid control account. Send through the same relay and sender identity used in production, and confirm the flag, the notice to the user and the way the address is restored after correction. Repeat the test after any change to the relay, the sending domain or the Moodle version, since these shift how bounces arrive and how they are read.

What inbound email-to-forum processing needs

Email-to-forum is a separate inbound path from outgoing mail, and it fails in different ways. Each component below has to be provisioned, secured and checked before replies from learners can post to a forum. Treat them as parallel parts of one design, since a gap in any one of them stops the whole flow.

A dedicated inbound mailbox

Moodle needs a mailbox that it can log into and read, separate from the noreply address used for outgoing messages. Use a mailbox that only the Moodle integration can access, with its own password or application credential. Do not share it with a person's inbox, because processing will read and remove messages. Confirm with your mail provider whether it allows the mailbox to be read by a service account.

IMAP or POP access settings

Moodle reads inbound mail over a mailbox protocol, and the supported options depend on your Moodle version. Confirm which protocols, ports and encryption modes your release accepts before you configure the mailbox. Check that your mail provider allows that protocol for the account and that firewall rules permit the connection from the web and cron servers.

The four-character mailprefix

The mailprefix setting in config.php is the tag Moodle uses to recognize reply addresses for email-to-module processing. It must be exactly four characters, so validate it before you deploy. Choose a value that does not collide with other mail sent from your domain, and record it in your configuration notes so that changes are reviewed.

config-dist.php

The inbound processing task

A scheduled task reads the mailbox, matches messages to posts, and then acts on them. Because it runs through cron, a stalled cron job means replies sit unprocessed in the mailbox. Confirm how the task behaves in your version, including how often it runs, how it handles messages it cannot match, and whether it deletes or moves processed mail.

Reply-address handling

Each reply address encodes the module and post that a message belongs to, so Moodle can route the reply correctly. Test that addresses are generated with the correct domain, that the mailbox receives them, and that replies from common mail clients keep the encoded address intact. Mail gateways that rewrite or strip addresses will break routing silently.

Mailbox and access controls

An inbound mailbox accepts mail from anyone on the internet, so it is an attack surface. Limit who can read the mailbox, store its credentials in a secrets store rather than plain configuration, and filter spam before messages reach Moodle. Review sender handling and logging with your security team, and confirm how bounced inbound messages are recorded.

Email setup by hosting environment

On a managed or self-hosted virtual machine, Moodle usually sends mail through an SMTP relay that your organization or mail provider operates. Moodle's outgoing mail settings in the site administration area point at that relay, and the server's own mail configuration rarely matters for Moodle itself. Most of the work is agreeing with the mail team which relay, port and sending identity Moodle may use, then proving that messages from that address pass the checks receiving servers apply.

  • Relay host and port: Confirm the hostname, port and whether TLS or STARTTLS is required, and who owns the account and credentials.
  • Sending address: Agree a noreply address on a domain you control, and confirm the relay is allowed to send for that domain.
  • SPF and DKIM: Ask the mail team to publish SPF and DKIM records for the relay and sending domain, and confirm the relay signs messages.
  • Bounce handling: Decide whether Moodle processes bounces, using the bounce settings in config-dist.php as the reference, and who reads the resulting notices.
  • Test path: Send test messages to external mailboxes and check the headers for SPF, DKIM and DMARC results before go-live.

Before you start, ask the mail provider for the exact relay hostname, the port and authentication method, and whether the relay has sending limits that your course notifications could reach.

Security and operational risks in Moodle email

Moodle email touches credentials, your domain's sender reputation and an inbound mailbox that accepts messages from the internet. The risks below connect because a weak choice in one area, such as an unauthenticated relay, often shows up as a delivery or spoofing problem later. Each card names the check to make before rollout.

SMTP credentials in config.php

The SMTP username and password for your relay are normally stored in config.php, so anyone who can read that file can send mail as your site. Restrict file permissions so only the deployment account and the web server user can read it, and keep the file out of version control. Plan a rotation schedule with the relay provider, and confirm that rotating the password does not require a full site outage. Record who holds the credential and where it is also stored.

Open relay exposure

If the mail relay accepts messages from any sender, spammers can use it and your domain can be blacklisted quickly. Confirm that the relay requires authentication from the Moodle server's address or credentials, and that it is not reachable from the public internet on an unauthenticated port. Test with an external check after any network change. Ask the relay operator to confirm the allowed sender list in writing.

Spoofing when SPF or DKIM is missing

Without SPF and DKIM records on your domain, receiving servers have little reason to trust that Moodle messages are genuine, and attackers can forge messages that appear to come from your institution. Publish SPF records that list your relay, and configure DKIM signing at the relay so messages carry a verifiable signature. Send a test message to a mailbox that shows authentication headers and confirm both checks pass.

DMARC policy alignment

DMARC tells receivers what to do when SPF or DKIM fails and the sender domain does not align with the visible From address. A Moodle noreply address on a different domain can pass SPF and DKIM yet still fail DMARC alignment. Check that the From domain matches the domain signed by DKIM, and review DMARC aggregate reports before tightening the policy. Confirm the policy with your mail team before moving from monitoring to enforcement.

Inbound mailbox abuse

Email-to-forum and other inbound processing read messages sent to a dedicated mailbox, so that mailbox is an entry point for spam, forged senders and oversized attachments. The mailprefix value must be exactly four characters for email-to-module processing, which narrows how addresses are matched. Restrict who can post, filter messages before they reach Moodle, and confirm that the mailbox is monitored by someone who can act on problems.

Monitoring bounce and queue logs

Bounce handling depends on settings such as handlebounces, minbounces and bounceratio in config.php, and those thresholds decide when Moodle stops mailing an address. Without someone reviewing bounce and queue logs, failed deliveries can go unnoticed for weeks, and a spike may signal a compromised account or a relay problem. Assign an owner, set an alert on sustained failures, and review the thresholds after each relay change.

Questions teams ask before setting up Moodle email

What does setting up Moodle email actually involve, and who does it?

Setting up Moodle email means pointing Moodle's outgoing mail at an SMTP relay your organization controls, choosing a sender address, publishing SPF and DKIM records for the sending domain, and setting bounce handling so undeliverable mail is noticed. Your mail or IT team usually owns the relay and DNS, while the Moodle administrator sets the values in the site. DeployOpen can plan and implement these settings in your infrastructure, with the work agreed in writing before it starts. The first step is listing every system that sends mail as or for your domain, because a single missing record often causes most delivery failures.

Can our team configure Moodle email without outside help?

Often yes, if your team already runs an SMTP relay and controls DNS for the sending domain. The Moodle settings are straightforward to enter, but the harder parts are agreeing which relay sends mail, confirming alignment between the From domain and the signing domain, and reading bounce results correctly. Teams without DNS access or mail administration experience usually need a partner or an internal mail specialist for those steps. Ask yourself who can change DNS records and who can rotate relay credentials before deciding.

What makes the effort for Moodle email larger or smaller?

Effort rises with the number of sending domains, the complexity of the relay, the volume of inbound mail, and how much DNS control your team has. Each additional domain or subdomain needs its own SPF and DKIM records and testing. A relay shared with other applications, or one requiring approvals for each change, adds coordination time. Email-to-forum processing adds an inbound mailbox, a mail-fetching method and a mailprefix to configure. Lower effort generally comes from one sending domain, a relay your team already runs, and a clear owner for DNS changes.

What do we need to provide before work starts on Moodle email?

You will typically need DNS access, or a named person who can publish records, for the sending domain. You also need SMTP relay details and credentials, a dedicated noreply address or mailbox, and, if you use email-to-forum, an inbound mailbox that Moodle can read. Confirm who approves credential creation and where secrets will be stored. Access to the Moodle administration account and the server that runs cron is also needed to test the configuration. Ask your team to confirm these items before scoping, since missing access is a common cause of delays.

How does Moodle handle bounces, and which settings control it?

Moodle's configuration file includes bounce handling settings named handlebounces, minbounces and bounceratio, which control when repeated delivery failures lead Moodle to stop sending to an address. Set these deliberately and document the values, because overly aggressive thresholds can silence valid users and overly loose ones keep sending to dead addresses. Review bounce results with your mail team, since the relay's own logs often explain failures that Moodle only records as a count. Confirm the exact behavior against the configuration file for your Moodle release.

What is involved in email-to-forum processing, and what can go wrong?

Email-to-forum lets users post to a Moodle forum by sending a message to a dedicated address. It needs an inbound mailbox, a method for Moodle to read it, and a mailprefix that must be exactly four characters for email-to-module processing. Common problems include mismatched addresses, messages from unknown senders being rejected, attachments exceeding limits and mail loops from automatic replies. Test with real senders from each user group, and confirm the mailbox is protected from general use, since anyone who learns the address can post.

What recurring work follows once Moodle email is live?

Once live, email needs ongoing attention: watching delivery and bounce trends, renewing or rotating relay credentials on a schedule your security policy sets, and keeping SPF and DKIM records current when senders change. DKIM keys may also need rotation, and any new integration that sends mail for your domain must be added to SPF before it is used. Plan a named owner, a review cadence and a change process for these tasks. Ongoing support and monitoring can be arranged as a retainer after the initial scope is delivered.

How outgoing and inbound Moodle mail flow

Outgoing mail starts when Moodle queues a notification and hands it to the SMTP relay you configure, which delivers it to recipients on the internet. Bounces travel back to the envelope sender on your domain, and the bounce settings in Moodle decide whether an address is suspended. Inbound mail to the dedicated mailbox is picked up by the email-to-forum processor. Check each boundary, since your relay, DNS and mailbox are outside Moodle's own control.

Outgoing Moodle mail, bounce return and email-to-forum processing across trust boundaries.

How DeployOpen scopes and delivers Moodle email

DeployOpen, a Chainscore Labs company, scopes Moodle email as a fixed, written scope agreed before any configuration starts. The scope names every item it covers: the SMTP relay and its credentials, the no-reply sender address, the sender authentication records (SPF and DKIM) on your domain, the bounce handling settings in the Moodle configuration, and inbound processing for email-to-forum if you use it. Each item has an owner on your side, usually someone who can change DNS records and mail relay settings, plus a named contact for the mail platform. Writing these down early prevents the common situation where the web team, the mail team and the Moodle administrator each assume another team owns the DNS entries or the bounce mailbox. The written scope also states what is out of scope, such as mailbox hosting or changes to your corporate mail platform, so procurement can compare quotes on the same basis.

DeployOpen delivers the work inside your own infrastructure, using your relay, your DNS and your Moodle instance. Configuration is applied through the settings your team reviews, and each change is tested with real messages to test accounts: account confirmation, password reset, course notifications, and a bounce test to a non-existent address. Evidence is recorded for each test, including headers that show SPF and DKIM results, the send and delivery timestamps, and the state of the bounce counters after the test. A handover document describes every setting changed, why it was set that way, and what to check after a Moodle upgrade or a DNS change. DeployOpen prepares configuration and evidence for your review, but it does not issue audit reports or attestations; if an assessor needs independent assurance on your mail controls, that comes from the auditor you engage. Ongoing support, periodic checks of sender authentication and bounce trends, and changes after a platform upgrade are available as a retainer.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.