[Django]-Add E-Mail header in django

8👍

you can try to use EmailMessage

from django.core.mail import EmailMessage


email = EmailMessage(
    'subject',
    'message.',
    'info@xyz1234.de',
    to=['MYTEST@yandex.ru'],
    headers={'MY-UNIQUE-HEAD':  '<http://www.xyz1234.de/unsubscribe123'},
)

email.send(fail_silently=False)

settings

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'YOURUSER@gmail.com'
EMAIL_HOST_PASSWORD = 'YOURPASS'

enter image description here

Leave a comment