Opened 2 years ago
Closed 2 years ago
#34783 closed Bug (invalid)
No module named 'smtp' when trying to send an email
| Reported by: | Rami Boutassghount | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Mail) | Version: | 4.2 |
| Severity: | Normal | Keywords: | mail, smtp, emailbackend |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I am not sure if it's a bug or not, but I mark it as that since I am just following the docs for setting up the Email Backend.
I get the Exception ModuleNotFoundError at /password/reset/ No module named 'smtp' when I just try to send an Email using the function send_mail.
Here is what I am using:
- Ubuntu 22.04
- Python 3.11.4
- Django 4.2.2
- EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
An here is the complete traceback.
ModuleNotFoundError Traceback (most recent call last)
Cell In[3], line 1
----> 1 send_mail("hello", "hi bro, what up?", "my-name@mysite.com", ["testing@hotmail.com"])
File ~/nicecv/venv/lib/python3.11/site-packages/django/core/mail/__init__.py:76, in send_mail(subject, message, from_email, recipient_list, fail_silently, auth_user, auth_password, connection, html_message)
54 def send_mail(
55 subject,
56 message,
(...)
63 html_message=None,
64 ):
65 """
66 Easy wrapper for sending a single message to a recipient list. All members
67 of the recipient list will see the other recipients in the 'To' field.
(...)
74 functionality should use the EmailMessage class directly.
75 """
---> 76 connection = connection or get_connection(
77 username=auth_user,
78 password=auth_password,
79 fail_silently=fail_silently,
80 )
81 mail = EmailMultiAlternatives(
82 subject, message, from_email, recipient_list, connection=connection
83 )
84 if html_message:
File ~/nicecv/venv/lib/python3.11/site-packages/django/core/mail/__init__.py:50, in get_connection(backend, fail_silently, **kwds)
42 def get_connection(backend=None, fail_silently=False, **kwds):
43 """Load an email backend and return an instance of it.
44
45 If backend is None (default), use settings.EMAIL_BACKEND.
(...)
48 constructor of the backend.
49 """
---> 50 klass = import_string(backend or settings.EMAIL_BACKEND)
51 return klass(fail_silently=fail_silently, **kwds)
File ~/nicecv/venv/lib/python3.11/site-packages/django/utils/module_loading.py:30, in import_string(dotted_path)
27 raise ImportError("%s doesn't look like a module path" % dotted_path) from err
29 try:
---> 30 return cached_import(module_path, class_name)
31 except AttributeError as err:
32 raise ImportError(
33 'Module "%s" does not define a "%s" attribute/class'
34 % (module_path, class_name)
35 ) from err
File ~/nicecv/venv/lib/python3.11/site-packages/django/utils/module_loading.py:15, in cached_import(module_path, class_name)
8 def cached_import(module_path, class_name):
9 # Check whether module is loaded and fully initialized.
10 if not (
11 (module := sys.modules.get(module_path))
12 and (spec := getattr(module, "__spec__", None))
13 and getattr(spec, "_initializing", False) is False
14 ):
---> 15 module = import_module(module_path)
16 return getattr(module, class_name)
File /usr/lib/python3.11/importlib/__init__.py:126, in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1204, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1176, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1126, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)
File <frozen importlib._bootstrap>:1204, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1176, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1140, in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'smtp'
Thank you for any help!
Change History (2)
comment:1 by , 2 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 2 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.