Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django EmailMessage.send() returns 0. What does that mean?

I have the following code in settings.py

#EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 687

(I tried using TLS = True and ports using Ports 25, 567, 465, 687 and also tried smtp.gmail.com and other HOSTS from MX records, but I always got a connection refused )

Then I tried using port 687 and commented TLS = True. I get return value "0" for the following code

from django.core.mail import EmailMessage
email = EmailMessage('Subject', 'Body', '[email protected]')
email.send()

I dont get any mail in my inbox. What does 0 mean ? What am I doing wrong ?

Any help would be appreciated,

Thanks,

Pankaj.

like image 431
Pankaj Bhambhani Avatar asked Nov 29 '25 05:11

Pankaj Bhambhani


1 Answers

The EmailMessage returns 0 if you haven't specified any recipients (to, bcc, cc). If you have no recipients the EmailMessage.send returns 0.

Also, Googles default smtp port is 587.

like image 113
hazmat Avatar answered Dec 01 '25 18:12

hazmat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!