0

Here is the code that I am using

    subject = 'Opinion - OTP for login'
    message = 'Your OTP to login is {}'.format(callbacktoken)
    email_from = 'Opinion@noreply.com'
    # email_from = settings.EMAIL_HOST_USER
    recipient_list = [email]
    send_mail(subject, message, email_from, recipient_list)

I expect the email to show Opinion@noreply.com as the name but they still show my email id that is in settings.EMAIL_HOST_USER.

How to solve this problem?

Sid
  • 378
  • 1
  • 13
  • Does the email `Opinion@noreply.com` or the domain `noreply.com` belong to you? You can only send emails from email addresses that belong to you (or domains). Otherwise you cannot do that unless the appropriate DKIM and / or SPF records are set by the domain (`noreply.com`) allowing you to send emails from them. – Abdul Aziz Barkat Jun 06 '21 at 08:08
  • @AbdulAzizBarkat Understood did not know that. I thought you could use any name. Others suggest it depends on the service gmail does not allow this – Sid Jun 06 '21 at 08:43

1 Answers1

0

You need to own the email, Sometimes email providers require to configure to allow sending emails through apps.

  • I found out that some providers like gmail do not allow name changing tho some do allow it. So email_from/from_email do not work if using gmail for sending mail. – Sid Jun 06 '21 at 14:31