0
Django 1.9.6從測試發送電子郵件
你能幫我理解這裏發生了什麼嗎?在settings.py中,我組織了一切發送郵件。
即:
EMAIL_HOST = 'smtp.mail.ru'
EMAIL_PORT = 2525
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'ggggggg'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '[email protected]'
SERVER_EMAIL = '[email protected]'
然後我已經準備了試驗:
from django.test import TestCase
from django.core.mail import send_mail
class GeneralTest(TestCase):
def test_sending_email(self):
number_of_successfully_delivered_messages = send_mail("Subject mail",
"Message mail",
'[email protected]',
['[email protected]'])
self.assertEqual(number_of_successfully_delivered_messages, 1)
,則測試通過。但是電子郵件並不屬於我。當我在django shell中嘗試它時,電子郵件到達。
您能評論一下這裏發生了什麼,以及在哪裏可以找到關於這種情況的文檔?
預先感謝您。