Updated 2026-11-20
How to Send Moodle Email Through SMTP
Moodle has SMTP built in, no plugin needed. Go to Site administration > Server > Email > Outgoing mail configuration, set SMTP hosts to smtp.bulko.io:587, SMTP security to TLS, SMTP auth type to LOGIN, enter your Bulko SMTP username and password, set a No-reply address on your own domain, save, then use Test outgoing mail configuration.
Moodle sends a lot of mail that users depend on: account confirmations, password resets, forum notifications and digests, assignment and grading notices, and messages to offline users. If SMTP hosts is left blank, Moodle falls back to PHP mail(), which needs a working local sendmail. On containers and most cloud VMs that either does nothing or sends from an IP address with no reputation, so mail silently vanishes or lands in spam.
Settings below are Moodle core, checked against the 4.5 LTS and 5.x source. One label differs: SMTP Auth Type in 4.x is written SMTP auth type from 5.0. Bulko is a send-only relay: it delivers what Moodle sends, it does not host mailboxes or offer IMAP.
Moodle SMTP settings
| Field | Value |
|---|---|
| SMTP hosts | smtp.bulko.io:587 (or smtp.bulko.io:2525, or smtp.bulko.io:465 with SSL) |
| SMTP security | TLS for 587/2525, SSL for 465 (never None) |
| SMTP auth type | LOGIN (PLAIN also works) |
| SMTP username | Your Bulko SMTP username (smtp_xxxxxxxxxxxxxxxx) |
| SMTP password | Your Bulko SMTP password |
| SMTP session limit | 1 by default; e.g. 20 to reuse one connection for several messages |
| No-reply address | [email protected] (on a domain you verified in Bulko) |
| Allowed email domains | Empty, or only your own verified domain(s) |
| DKIM selector | Leave empty (Bulko signs verified domains) |
Forcing the settings in config.php
Every field on the Outgoing mail configuration page is a $CFG setting, so you can pin it in config.php (see the snippet below). Moodle then shows the field as Defined in config.php and nobody can change it from the web UI; it also keeps the relay password out of database backups. Put the lines above require_once(__DIR__ . '/lib/setup.php');.
- On a staging copy use
$CFG->noemailever = true;or$CFG->divertallemailstoso tests never mail real students.
Step-by-step setup
- Buy an SMTP package on the Bulko SMTP Relay page and copy the username and password from SMTP Access in the dashboard. Under Sending domains, verify the domain your Moodle no-reply address uses so Bulko DKIM-signs it.
- Log in as a site administrator and open Site administration > Server > Email > Outgoing mail configuration (
/admin/settings.php?section=outgoingmailconfig). - In SMTP hosts enter
smtp.bulko.io:587. Without:587Moodle connects to port 25, which Bulko does not offer. - Set SMTP security to TLS (use SSL only together with port 465) and SMTP auth type to LOGIN. XOAUTH2 (shown only when an OAuth 2 service is enabled) is not for Bulko.
- Fill in SMTP username and SMTP password. Optionally raise SMTP session limit (for example to 20) so cron sends batches over one connection instead of reconnecting for every message.
- Under No-reply and domain set No-reply address to an address on your verified domain, e.g.
[email protected]. Moodle also uses it as the envelope sender. Leave Allowed email domains empty unless you understand the From rules below. - Click Save changes. The test page only uses saved values.
- Make sure cron runs every minute (
php admin/cli/cron.php); forum and notification mail is sent by cron, not by the page request.
config.php (optional: force the SMTP settings)
<?php // config.php in the Moodle root, above the require_once line
// ... database, wwwroot, dataroot settings ...
// Outgoing mail through Bulko (fields become read-only in the admin UI)
$CFG->smtphosts = 'smtp.bulko.io:587';
$CFG->smtpsecure = 'tls'; // '' = None, 'ssl' (port 465), 'tls' (587/2525)
$CFG->smtpauthtype = 'LOGIN'; // or 'PLAIN'
$CFG->smtpuser = 'smtp_xxxxxxxxxxxxxxxx';
$CFG->smtppass = 'YOUR_BULKO_SMTP_PASSWORD';
$CFG->smtpmaxbulk = 20; // SMTP session limit
$CFG->noreplyaddress = '[email protected]';
require_once(__DIR__ . '/lib/setup.php'); // Do not edit
Cron, forum mail and the 2,000-per-day budget
The scheduled task Forum mailings and maintenance jobs (mod_forum\task\cron_task) runs every minute and queues ad hoc tasks that send post notifications, and only after Maximum time to edit posts (Site administration > Security > Site security settings, default 30 minutes) has passed. Digests go out on the first cron after Hour to send digest emails (forum settings, default 17:00). If cron is not running, the test email works but nothing else arrives.
Each Bulko SMTP access sends up to 2,000 emails per day. Size it the way Moodle sends:
- One post in a forum with forced subscription in a 400-student course is 400 emails.
- Set Email digest type under Site administration > Users > Accounts > User default preferences to Complete (daily email with full posts) or Subjects so new users get one daily email instead of one per post.
- Moodle uses one SMTP username for everything. You can list several hosts separated by semicolons (
host1:587;host2:587), but PHPMailer treats that as a failover order, not load balancing, and with the same credentials. You cannot spread one Moodle site across several Bulko SMTP accesses; above 2,000 per day, cut volume with digests. - Failures are logged as Email failed to send and in cron output as
Error: lib/moodlelib.php email_to_user(): ....
Send a test email
Use the link at the bottom of the settings page or open /admin/testoutgoingmailconf.php (Test outgoing mail configuration). Fill in To email address, optionally From username or email address and Additional subject, then click Send a test message.
Success reads This site has successfully sent a test message to the mail server, followed by From and To. It only means the relay accepted it; check headers for dkim=pass with your domain. On failure the page temporarily switches on SMTP debugging and prints the whole SMTP conversation, which tells you exactly where it stopped. Your site couldn't communicate with your mail server with no log means Moodle never got a connection.
Then post in a test forum and wait for cron to check the real notification path.
No-reply address, Allowed email domains and DMARC
Most Moodle mail is sent on behalf of a person. Who appears in From depends on:
- Allowed email domains empty (default): every message uses the No-reply address as From, with the sender's name shown as Teacher Name (via SITE) when Email via information is on, and Reply-To set to the no-reply address. Safest: all mail is on your DKIM-signed domain.
- Domains listed there: messages from users whose address is on a listed domain (and whose email is visible to the recipient) are sent with their real address in From. List only domains you control and have verified in Bulko. Adding
gmail.comor a student email provider makes Moodle send mail as that domain, which fails DMARC and gets rejected or junked. - DKIM selector signs mail inside Moodle with a key in
$CFG->dataroot/dkim/<domain>/<selector>.private. Not needed with Bulko domain verification; if used, avoid the selectorbk1.
Troubleshooting
| Problem | Fix |
|---|---|
| SMTP Error: Could not authenticate. (server replied 535) | Wrong username or password, or a mail-provider password typed in. Copy both values again from SMTP Access in the Bulko dashboard, check that a password manager did not autofill SMTP password, and keep SMTP auth type at LOGIN or PLAIN. More in <a href="/en/smtp-errors/535/">SMTP error 535</a>. |
| Test hangs, then SMTP connect() failed. or Could not connect to SMTP host | Port and SMTP security do not match. Use smtp.bulko.io:587 or :2525 with TLS, or smtp.bulko.io:465 with SSL. SSL on 587 or TLS on 465 times out. |
| Authentication fails although the password is right, SMTP security is None | Moodle disables PHPMailer's automatic STARTTLS, so with None it never encrypts the session on 587 and the relay refuses to log in. Set SMTP security to TLS. |
| Your site couldn't communicate with your mail server (no SMTP log) | Outbound SMTP is blocked by the host or the host name has a typo. Test with openssl s_client -starttls smtp -connect smtp.bulko.io:587; if 587 is filtered, use :2525 with TLS. |
| Test email arrives, forum posts and notifications do not | Cron is not running or is failing. Check Site administration > Server > Tasks > Scheduled tasks, run php admin/cli/cron.php by hand and read its output; remember the 30-minute editing delay and digest users. |
| Mail goes to spam or is rejected with a DMARC error | From is on a domain not verified in Bulko, often because Allowed email domains lists an outside domain. Empty that field, use a No-reply address on your verified domain and add the DKIM record. |
Bounces and reply-by-email need your own mailbox
Bulko only relays outgoing mail. Two Moodle features need mail coming back in, and that stays with your mailbox provider:
- Incoming mail configuration (Site administration > Server > Email) for forum reply-by-email and similar handlers: Moodle polls an IMAP mailbox on your mail server; Bulko has no IMAP.
- Bounce counting (
$CFG->handlebounceswithmailprefix/maildomainin config.php) sets the envelope sender to a generated address onmaildomain, which must be a mail system you run that hands bounces back to Moodle. Leave it off unless you already have that set up.
Otherwise suspend accounts with dead addresses yourself.
FAQ
Do I need a plugin to use SMTP in Moodle?
No. SMTP is part of Moodle core under Site administration > Server > Email > Outgoing mail configuration.
Which port and security setting should Moodle use?
SMTP hosts smtp.bulko.io:587 with SMTP security TLS. If 587 is blocked use :2525 with TLS, or :465 with SSL. Always include the port, otherwise Moodle uses 25.
Can I keep using Gmail or Microsoft 365 SMTP instead?
Moodle supports XOAUTH2 for them via an OAuth 2 service, but sending limits and policy changes apply. Microsoft is turning off SMTP AUTH basic authentication by default, see <a href="/en/smtp-relay/microsoft-365-basic-auth/">Microsoft 365 SMTP basic auth</a>.
Why do forum emails arrive late?
Moodle waits until the editing time (30 minutes by default) is over, then cron sends them. Digest subscribers get one email after the configured digest hour.
Can students reply to forum emails through Bulko?
Not through Bulko. Reply-by-email uses Incoming mail configuration with an IMAP mailbox at your own mail provider; Bulko only handles the outgoing side.
How much does it cost?
Bulko SMTP Relay is a one-time package: $5 for 5,000 emails, $15 for 20,000, $30 for 50,000 or $60 for 150,000. No subscription, unused emails do not expire; each access sends up to 2,000 per day.
Get SMTP credentials for Moodle
One-time payment by card or crypto, no subscription. Unused emails never expire. 2,000 emails per day per SMTP account.
What you can send: Acceptable Use Policy.