Send email from Elmah?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
ELMAH can send email notifications when an ASP.NET application logs an unhandled error. The feature is built around the mail module and standard ASP.NET mail settings, so the real job is configuring ELMAH and SMTP correctly. Once that is in place, ELMAH will email a formatted error report whenever a matching exception is captured.
What ELMAH Actually Sends
Classic ELMAH for ASP.NET can log errors to different backends and optionally notify you by email. The mail feature is useful when you want immediate visibility into production failures without constantly checking the error log UI.
The usual flow is:
- ELMAH captures an exception
- the mail module formats an error message
- ASP.NET SMTP settings are used to send the email
That means a working SMTP setup is just as important as the ELMAH configuration itself.
Basic web.config Setup
A typical configuration includes the ELMAH error mail module and an SMTP section.
This is the core idea: ELMAH defines who should receive the notification, and system.net defines how to send it.
Make Sure the Module Is Active
In classic ASP.NET applications, ELMAH must be registered in the app's module pipeline. If the mail configuration exists but the module is not active, no emails will be sent.
The exact registration style depends on the app and IIS mode, but the important point is operational: verify that ELMAH is actually capturing errors before debugging the mail path.
A good first test is to trigger a known exception and confirm that it appears in the ELMAH error log UI or storage backend.
Filtering Which Errors Send Mail
Sending an email for every exception can become noisy fast. Many teams filter common or low-value errors so inboxes stay useful.
Examples you may want to suppress:
- 404 errors for missing assets
- crawler noise
- known handled exceptions that are already monitored elsewhere
The exact filter setup depends on the ELMAH version and hosting model, but the operational rule is the same: treat email as a signal channel, not a dumping ground.
SMTP Problems Are Often the Real Issue
If ELMAH logs the exception but no email arrives, the failure is often outside ELMAH itself.
Common causes:
- wrong SMTP host or port
- invalid credentials
- SSL or TLS mismatch
- firewall blocks
- sender address rejected by the mail server
That is why it is useful to validate the SMTP settings independently. If the application cannot send ordinary mail, ELMAH mail will fail too.
A Practical Testing Approach
Use a staging environment or a deliberate test exception.
If the exception is logged but no email arrives, investigate the SMTP path. If nothing is logged at all, fix ELMAH pipeline registration first.
Common Pitfalls
The biggest mistake is assuming ELMAH mail is broken when the real issue is invalid SMTP configuration.
Another mistake is enabling email for every logged exception and then creating alert fatigue.
A third issue is testing mail before confirming that ELMAH is actually recording the error in the first place.
Summary
- ELMAH can send error emails through its mail module plus standard ASP.NET SMTP settings
- Configure both the ELMAH
errorMailsection and thesystem.netSMTP section - Verify that ELMAH is logging exceptions before troubleshooting email delivery
- Filter low-value errors so notification email remains useful
- Most mail failures come from SMTP configuration, credentials, or transport issues rather than ELMAH itself
Related reading
- Sending information to a ngnix from php on the same server without http
- Sending metrics from kafka to grafana
- Serve trained Tensorflow model with REST API using Flask?
- server could not find the requested resource get pods error when deploying Helm chart using Jenkins
- Send HTTP POST request in .NET
- Send HTTP POST request in .NET
- Server Sent Events In a Kubernetes Cluster
- Serverless framework deployment error You're not authorized to access this resource

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.