Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have configured postfix as a null client on my machine and the configuration also seems to be working, as

$ echo "test" | mail -s "test" -r "sender@domain.com" recipient@domain.com

successfully delivers the email. however if i try to use it with django with the following settings:

EMAIL_HOST = "localhost"
EMAIL_PORT = 25
EMAIL_HOST_USER = ""
EMAIL_HOST_PASSWORD = ""
DEFAULT_FROM_EMAIL = "sender@domain.com"
SERVER_EMAIL = "sender@domain.com"

the process get's stuck without an error being raised:

from django.core.mail import send_mail
from django.conf import settings

send_mail(subject="test", message="test", from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=["recipient@domain.com"])

i can't figure out why this function get's stuck, the /var/log/mail.log file is also empty.

Edit: Note, that sender@domain.com and recipient@domain.com are both valid adresses but i replaced them in this question.

Edit: When setting EMAIL_TIMEOUT = 10 in settings.py, i get the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/smtplib.py", line 391, in getreply
    line = self.file.readline(_MAXLINE + 1)
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "venvpath/lib/python3.8/site-packages/django/core/mail/__init__.py", line 61, in send_mail
    return mail.send()
  File "venvpath/lib/python3.8/site-packages/django/core/mail/message.py", line 284, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "venvpath/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
    new_conn_created = self.open()
  File "venvpath/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 62, in open
    self.connection = self.connection_class(self.host, self.port, **connection_params)
  File "/usr/lib/python3.8/smtplib.py", line 253, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.8/smtplib.py", line 341, in connect
    (code, msg) = self.getreply()
  File "/usr/lib/python3.8/smtplib.py", line 394, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed: "
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
972 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...