MS Graph API Mailer

Local plugins ::: local_msgraph_api_mailer
Maintained by KRISHNA KANT Gupta
This plugin replaces SMTP email sending with Microsoft Graph API for all Moodle emails, allowing you to bypass SMTP restrictions from hosting providers. Routes all Moodle outgoing emails through Microsoft Graph API using Azure AD OAuth2 — no SMTP server required. Supports large attachments up to 150 MB, email logging, SMTP fallback, and includes a built-in test and validate page.
Latest release:
2 sites
23 downloads
1 fans
Current versions available: 1

MS Graph API Mailer replaces Moodle's built-in SMTP email delivery with Microsoft Graph API, routing all outgoing emails through Microsoft 365 / Azure AD using OAuth2 client credentials — no SMTP server or password required.

Key Features

  • Zero-SMTP setup — authenticates via Azure AD app registration (tenant ID, client ID, client secret); no mail server configuration needed
  • Drop-in replacement — intercepts all Moodle outgoing emails transparently via the phpmailer_init hook; no core file modifications required beyond an auto-applied patch to moodle_phpmailer.php
  • Large attachment support — files under the threshold (default 3 MB) are sent inline; larger files (up to 150 MB) are automatically uploaded via the Microsoft Graph upload session API (chunked PUT)
  • MIME detection — detects file type from magic bytes for extensionless temp files (e.g. Moodle scheduled report attachments), automatically appending the correct extension
  • SMTP fallback — optionally falls back to Moodle's configured SMTP if the Graph API call fails
  • Email divert support — fully respects Moodle's $CFG->divertallemailsto and $CFG->divertallemailsexcept settings
  • Email log viewer — searchable, filterable table of all sent and failed emails with recipient, subject, response, attachment indicator, and CSV export
  • Connection status badge — settings page auto-checks Azure connectivity on load and displays a live green/red badge
  • Test & Validate page — dedicated page to check permissions, send a plain test email, and send a test email with a real .xlsx attachment to verify the full delivery pipeline
  • Mandatory field validation — the plugin cannot be enabled until all required Azure credentials are filled in

Requirements

  • Moodle 5.1 or later
  • PHP 8.3 or later
  • A Microsoft 365 / Azure AD app registration with the Mail.Send application permission granted

Setup

  1. Install the plugin
  2. Go to Site administration > Plugins > MS Graph API Mailer
  3. Enter your Azure Tenant ID, Client ID, Client Secret, and Sender Email Address
  4. Click Check Permissions to verify connectivity
  5. Enable the plugin

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

KRISHNA KANT Gupta (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments

Show comments
Please login to post comments