smtp zoho django code example

Example: smtp zoho django

from django.core import mail
    mail.send_mail(subject='Hello',
                   message='Body goes here',
                   from_email='[email protected]',
                   recipient_list=['[email protected]'])
                                       
to this:

    from django.core.mail import EmailMessage
    email = EmailMessage(
        subject='Hello',
        body='Body goes here',
        from_email='[email protected]',
        to=['[email protected]'],
        reply_to=['[email protected]'],
        headers={'Content-Type': 'text/plain'},
    )
    email.send()

Other Zoho mail settings:

    EMAIL_HOST = 'smtp.zoho.com'
    EMAIL_HOST_USER = '[email protected]'
    EMAIL_HOST_PASSWORD = 'password'
    EMAIL_PORT = 587
    EMAIL_USE_TLS = True
    EMAIL_USE_SSL = False