Opened 10 years ago
Closed 10 years ago
#24419 closed New feature (fixed)
Provide an easy way to test email connection
Reported by: | Gavin Wahl | Owned by: | Loek van Gent |
---|---|---|---|
Component: | Core (Mail) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | cmawebsite@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When configuring django to send emails through an SMTP server, there are usually many different settings to try to get it to work. I've written a management command that just sends an email to make testing the settings easier. I'm wonder if there's any interest in including this command in django?
Here's the command: https://github.com/fusionbox/django-fusionbox/blob/master/fusionbox/core/management/commands/send_test_email.py
Change History (8)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
I don't see much advantage to a management command compared to opening a shell and invoking send_mail()
as you see fit (besides saving some keystrokes).
comment:3 by , 10 years ago
Summary: | Testing email settings → Provide an easy way to test email connection |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
From the mailing list thread:
Russ: "However, the counterpoint to that is that you can't just reload settings, so you have to retype (or rely on command history). I agree the benefit is marginal, but I think it's a nice enough convenience, and it's not going to be a major maintenance overhead, so I think it's probably worth including."
aRkadeFR: "But if I take a step back, these commands (for my projects) are only here to test that my SMTP settings are well setup. Thus, the test sending email is quite unnecessary, I would like a check that connects to the SMTP server (if the emails settings are setup else do nothing) when the application starts. (I don't know if there's something like saying to a SMTP server: am I allowed here? without sending an actual email)"
Tom (reply to aRkadeFR): "In Simple Mail Transfer Protocol terms, it definitely is (EHLO, MAIL FROM, RCPT TO, then disconnect without sending DATA). But SMTP is not the only mail backend, and smptlib does not expose that level of connection detail - it will merely raise a different exception type if any of those commands do not return 250 status."
comment:4 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 10 years ago
Has patch: | set |
---|
Please review https://github.com/django/django/pull/4263
comment:6 by , 10 years ago
Did you consider the comments from the mailing list thread about testing SMTP settings only without sending a mail? If it's feasible and not too difficult, I find that a bit more useful than simply duplicating send_mail()
.
comment:7 by , 10 years ago
Something like this throws an error when SMTP creds are wrong:
from django.core import mail from django.core.mail.backends.smtp import EmailBackend def _check_mail_settings(self): connection = mail.get_connection() if isinstance(connection, EmailBackend): connection.open()
But I think this should be a new ticket/feature. This ticket, to me, is really about sending an actual mail. Could I propose a new ticket to create testconnections
(like @imgraham suggested) that's to test other connections (cache, ...) as well?
The django developers list is usually the best place to discuss new features.
My thoughts on your code:
Maybe it would be more useful to try to mimic the unix mail/sendmail commands, so you can use it even for non testing situations.