6

非常にスタンジエラーが発生しました。Mac OSXでDjangoを実行していますが、アプリケーションからメールを送信しようとすると、ハングして次のエラーが表示されます:「エラー61接続が拒否されました」

何か案は?ファイアウォールをオンにしていません。必要に応じて、エラーの画像をアップロードできます。

4

4 に答える 4

4

実際にEMAIL_*settings.pyで設定を構成しましたか?エラー61は、デフォルト値のままにして、ローカルSMTPサーバーを実行していない場合に発生するエラーです。

または、Peterが提案しているように、設定している場合は、SMTPサーバーで認証を使用する必要がある場合があります。

于 2010-04-20T06:31:09.113 に答える
1

sendmailがコマンドライン経由で機能する場合は、その単純なコードをhttp://djangosnippets.org/snippets/1864/からsendmail.pyというファイルにコピーします。

"""sendmail email backend class."""

import threading

from django.conf import settings
from django.core.mail.backends.base import BaseEmailBackend
from subprocess import Popen,PIPE

class EmailBackend(BaseEmailBackend):
    def __init__(self, fail_silently=False, **kwargs):
        super(EmailBackend, self).__init__(fail_silently=fail_silently)
        self._lock = threading.RLock()

    def open(self):
        return True

    def close(self):
        pass

    def send_messages(self, email_messages):
        """
        Sends one or more EmailMessage objects and returns the number of email
        messages sent.
        """
        if not email_messages:
            return
        self._lock.acquire()
        try:
            num_sent = 0
            for message in email_messages:
                sent = self._send(message)
                if sent:
                    num_sent += 1
        finally:
            self._lock.release()
        return num_sent

    def _send(self, email_message):
        """A helper method that does the actual sending."""
        if not email_message.recipients():
            return False
        try:
            ps = Popen(["sendmail"]+list(email_message.recipients()), \
                       stdin=PIPE)
            ps.stdin.write(email_message.message().as_string())
            ps.stdin.flush()
            ps.stdin.close()
            return not ps.wait()
        except:
            if not self.fail_silently:
                raise
            return False
        return True

settings.py内で、変数を設定します。

EMAIL_BACKEND = 'path.to.sendmail.EmailBackend'
于 2012-07-17T05:18:31.680 に答える
1

Max OS Xを完全に知らないので、私の最初の推測では、SMTPサーバーには認証が必要です。

于 2010-04-20T03:39:56.397 に答える
0

同様の問題があり、次のリンクを見つけました: http://dashasalo.com/2011/05/29/django-send_mail-connection-refused-on-macos-x/

基本的に、そこからメールを送信するには、メール サーバーを実行する必要があります。実行中のメール サーバーがない場合は、61 が返されます。

于 2011-10-20T02:46:26.153 に答える