在使用Django的邮件程序时,如果没有使用PINAX,可以按照以下步骤进行配置:
pip install django
示例配置如下:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.example.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'your_email@example.com'
EMAIL_HOST_PASSWORD = 'your_password'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'your_email@example.com'
from django.core.mail import EmailMessage
subject = 'Test email'
body = 'This is a test email.'
to = ['recipient@example.com']
email = EmailMessage(subject, body, to=to)
email.send()
以上就是使用Django的邮件程序的基本步骤。如果需要更详细的教程,可以参考Django官方文档:https://docs.djangoproject.com/en/4.1/topics/email/
如果需要使用PINAX,可以参考PINAX官方文档:https://pinaxproject.com/pinax/mail/
领取专属 10元无门槛券
手把手带您无忧上云