Problem / Motivation
When a site sends a large volume of emails (for example, newsletters to thousands of subscribers), the SMTP module
currently creates an individual log entry for every recipient. This produces excessive log noise on most production
sites and makes it harder to surface real errors or warnings.
Site owners and developers need a configurable logging verbosity that follows Drupal's / PSR-3 log levels
(debug, info, notice, warning, error,
critical, etc.). Dedicated mail-log modules already exist for projects that require detailed
per-message tracking; the SMTP module should default to a reasonable level of verbosity and allow administrators to
choose a different level.
Steps to reproduce
- Send a bulk mailing through the SMTP module (e.g., a newsletter to several thousand users).
- Visit Reports → Recent log messages and filter on the SMTP logger.
- Observe one entry per recipient at the current (too-verbose) log level.
Proposed resolution
Add a configuration setting to the SMTP module that selects the minimum PSR-3/Drupal log level at which SMTP events
are written. The setting should live at /admin/config/system/smtp and present the standard PSR-3 levels
as options. The module should only write per-message log entries when the configured log level is equal to or more
verbose than the level assigned to that event.
Suggested default: warning (so that routine successful sends are not logged, but warnings/errors still
are). Administrators who need per-message traces can set the level to info or debug, or
install a dedicated mail logging module for full message auditing.
User interface changes
- Add a new setting to
/admin/config/system/smtp:
(In a Drupal config form this would be a#type => 'select'with\Psr\Log\LogLevel
constants as values.) - Add explanatory help text: "Select the minimum log level at which SMTP events are recorded. Use
debug or info for per-message logging; warning or higher
is recommended for production."
API changes
- No public API changes required. Internally, use the configured log level when writing messages.
- Example code (inside the SMTP send routine) that respects the configured level:
Data model changes
No persistent data-model changes required. This is a configuration change only (e.g.,
smtp.settings:log_level).
Remaining tasks
- Add the config form element to the SMTP config form and save to config.
- Implement a robust level-comparison helper (map PSR-3 names to numeric severities) and unit tests.
- Replace direct calls that write per-message log entries with the conditional logging approach above.
- Update README and module docs to document the new setting and recommended production default.
- Consider a follow-up feature: an option to log only failures (i.e., log on
error+), or integration
guidance for dedicated mail-audit modules.
This approach makes SMTP logging conform to PSR-3 / RFC-style log levels, reduces production noise by default, and
gives site administrators a straightforward way to request more (or less) verbosity when needed.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | smtp_settings.png | 17.38 KB | ritarshi_chakraborty |
Issue fork smtp-3556311
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ritarshi_chakraborty commentedWorking on it.
Comment #4
ritarshi_chakraborty commentedComment #5
bluegeek9 commentedComment #9
bluegeek9 commentedComment #11
bluegeek9 commented