I tested Django send_mail()
function which I needed for a project. I had the EMAIL_HOST
set to the SMTP server provider my company uses, EMAIL_PORT
to 587, EMAIL_USE_TLS
to True. Both EMAIL_HOST_USER
and EMAIL_HOST_PASSWORD
was set to "" (empty string).
Then I used the send_mail
as:
from djanog.core import mail
mail.send_mail(
"Django mail sample",
"Body",
"myemail@example.com",
["myemail@example.com"]
)
But calling the view actually sent the email to my mail from my mail, but I didn't provide any password at all. I also set recipient_list
to my colleague's mail, it worked. Then I tried to change the from_email
to my colleague's mail it didn't work.
I have my mail setup in Thunderbird in my system.
So how did Django sent the mail without my email's password? Was it because of my setup in Thunderbird? What happened exactly?
Update:
My colleague tried the same in his system, which doesn't have any mail configured. When running the result was an
SMTPRecipientsRefused
.I used both my Phone's network as Hotspot and my company's Hotspot both worked. But in my colleague's system nothing worked.
When setting
EMAIL_USER_HOST
andEMAIL_HOST_PASSWORD
in my colleague's system it worked.