SMTP backend¶
6153 단어 smtp
SMTP backend ¶
This is the default backend. Email will be sent through a SMTP server. The server address and authentication credentials are set in the EMAIL_HOST , EMAIL_PORT , EMAIL_HOST_USER , EMAIL_HOST_PASSWORD and EMAIL_USE_TLS settings in your settings file.
The SMTP backend is the default configuration inherited by Django. If you want to specify it explicitly, put the following in your settings:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
SMTPConnection objects
Prior to version 1.2, Django provided a SMTPConnection class. This class provided a way to directly control the use of SMTP to send email. This class has been deprecated in favor of the generic email backend API.
For backwards compatibility SMTPConnection is still available in django.core.mail as an alias for the SMTP backend. New code should use get_connection() instead.
Console backend ¶
Instead of sending out real emails the console backend just writes the emails that would be send to the standard output. By default, the console backend writes to stdout. You can use a different stream-like object by providing the stream keyword argument when constructing the connection.
To specify this backend, put the following in your settings:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
This backend is not intended for use in production -- it is provided as a convenience that can be used during development.
File backend ¶
The file backend writes emails to a file. A new file is created for each new session that is opened on this backend. The directory to which the files are written is either taken from the EMAIL_FILE_PATH setting or from the file_path keyword when creating a connection with get_connection() .
To specify this backend, put the following in your settings:
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location
This backend is not intended for use in production -- it is provided as a convenience that can be used during development.
In-memory backend ¶
The 'locmem' backend stores messages in a special attribute of the django.core.mail module. The outbox attribute is created when the first message is sent. It's a list with an EmailMessage instance for each message that would be send.
To specify this backend, put the following in your settings:
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
This backend is not intended for use in production -- it is provided as a convenience that can be used during development and testing.
Dummy backend ¶
As the name suggests the dummy backend does nothing with your messages. To specify this backend, put the following in your settings:
EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
This backend is not intended for use in production -- it is provided as a convenience that can be used during development.
Defining a custom email backend ¶
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C# SMTP를 이용한 비동기식 메일 보내기C#메일 수신 기능을 사용하려면 두 개의 네임스페이스 시스템이 필요합니다.Net;및 시스템.Net.Mail; 비동기적으로 메일을 보내기 때문에, 비동기적으로 완료될 때 응답 이벤트를 추가해야 합니다client_Sen...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.