Django does't send email on the remote server

493 views
Skip to first unread message

Sergei Sokov

unread,
Feb 23, 2021, 5:06:09 AM2/23/21
to Django users
I am trying to send an email when a user fills out a form on my site.
Everything works on my local server, letters are sent and I am got them.
On a remote timeweb.com server with the same settings, letters are not sent.
Tried DEBUG = False and True
I tried different mail services: gmail, mail, yandex, timeweb mail.
In gmail included "Unreliable applications that have access to the account".
Nothing helps.

Who knows, please tell me where to dig.

Anubhav Gupta

unread,
Feb 23, 2021, 6:05:25 AM2/23/21
to django...@googlegroups.com
alse please share the program to have a look on

On Tue, Feb 23, 2021 at 3:57 PM Anubhav Gupta <anubhavg...@gmail.com> wrote:
you should be using app password instead of less secure option 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9c081e17-30ad-4bf9-9728-6b3010b3736an%40googlegroups.com.

Anubhav Gupta

unread,
Feb 23, 2021, 6:05:27 AM2/23/21
to django...@googlegroups.com
you should be using app password instead of less secure option 

On Tue, Feb 23, 2021 at 3:36 PM Sergei Sokov <soko...@gmail.com> wrote:
--

Sergei Sokov

unread,
Feb 23, 2021, 6:15:06 AM2/23/21
to Django users

'setting.py'

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST_USER = "em...@gmail.com"
EMAIL_HOST = "smtp.gmail.com" EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_PASSWORD = "Your_Password"

    I have chtcked spam, I have tried different email services   
    I switched the security allow less secure app on
вторник, 23 февраля 2021 г. в 12:05:27 UTC+1, anubhavg...@gmail.com:

ramadhan ngallen

unread,
Feb 23, 2021, 7:42:16 AM2/23/21
to 'MH' via Django users
Change 
EMAIL_PORT = 465
EMAIL_USE_TLS=False 
EMAIL_USE_SSL=True 

On your sendmail function set sail_silently=False so that we can  see an error on terminal

ule...@gmail.com

unread,
Feb 23, 2021, 12:42:42 PM2/23/21
to Django users
I have this same problem when i use smtp = out.telenet.be
on my local server it works fine but when it use pythonanywhere.com i get OSError: [Errno 101] Network is unreachable

Op dinsdag 23 februari 2021 om 11:06:09 UTC+1 schreef soko...@gmail.com:

ule...@gmail.com

unread,
Feb 25, 2021, 3:26:56 PM2/25/21
to Django users
Any solution ?

Op dinsdag 23 februari 2021 om 18:42:42 UTC+1 schreef ule...@gmail.com:

Mike Dewhirst

unread,
Feb 25, 2021, 3:44:53 PM2/25/21
to django...@googlegroups.com
On 26/02/2021 7:26 am, ule...@gmail.com wrote:
> Any solution ?

You need a friendly sysadmin from your mail provider. Nowadays with so
much spam and botnet activity there are  many email relay checks and
hurdles to deal with. Your remote server has to be established with your
provider and recognised as a bona fide sender.

>
> Op dinsdag 23 februari 2021 om 18:42:42 UTC+1 schreef ule...@gmail.com:
>
> I have this same problem when i use smtp = out.telenet.be
> <http://out.telenet.be>
> on my local server it works fine but when it use
> pythonanywhere.com <http://pythonanywhere.com> i get OSError:
> [Errno 101] Network is unreachable
>
> Op dinsdag 23 februari 2021 om 11:06:09 UTC+1 schreef
> soko...@gmail.com:
>
> I am trying to send an email when a user fills out a form on
> my site.
> Everything works on my local server, letters are sent and I am
> got them.
> On a remote timeweb.com <http://timeweb.com> server with the
> same settings, letters are not sent.
> Tried DEBUG = False and True
> I tried different mail services: gmail, mail, yandex, timeweb
> mail.
> In gmail included "Unreliable applications that have access to
> the account".
> And here I included
> https://accounts.google.com/DisplayUnlockCaptcha
> <https://accounts.google.com/DisplayUnlockCaptcha>
> Nothing helps.
>
> Who knows, please tell me where to dig.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/671d189a-3fc3-426b-a579-18e8f08421b9n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/671d189a-3fc3-426b-a579-18e8f08421b9n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


OpenPGP_signature

ule...@gmail.com

unread,
Feb 25, 2021, 3:53:26 PM2/25/21
to Django users
i can send email when i use a local server 127.0.0.1:8000 but when i use pythonanywhere.com or eu.pythonanywhere.com 
i can not send mails....

Op donderdag 25 februari 2021 om 21:44:53 UTC+1 schreef Mike Dewhirst:

Sergei Sokov

unread,
Feb 26, 2021, 1:09:24 PM2/26/21
to Django users
This code is working
server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login('k...@gmail.com', 'pas')
    try:
        server.sendmail('k...@gmail.com', 's...@gmail.com', body_mes.encode('utf-8')) print('ok')
     except:
         print('An error occurred when trying to send an email')

четверг, 25 февраля 2021 г. в 21:53:26 UTC+1, ule...@gmail.com:

Class Udeh

unread,
Feb 26, 2021, 6:39:00 PM2/26/21
to django...@googlegroups.com
Hello,
Try sent the environment variables in ur hosting platform config..so it read the .env files from your hosting...and most time gmail not advisable to use as a mail option u can use sendmail  or mailgun..had same issue when deploying with heroku but I had to use the heroku add-ons mail services and also set the config var in the heroku platform it works.


From: django...@googlegroups.com <django...@googlegroups.com> on behalf of Sergei Sokov <soko...@gmail.com>
Sent: Friday, February 26, 2021 7:09:24 PM
To: Django users <django...@googlegroups.com>
Subject: Re: Django does't send email on the remote server
 
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/24577fe3-f08c-446a-9b95-156abced57ccn%40googlegroups.com.

AMRIT SHAHI

unread,
Mar 3, 2021, 11:58:10 PM3/3/21
to django...@googlegroups.com
is that your site backend is fully backend

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Malcolm MacKinnon

unread,
Mar 4, 2021, 12:56:47 AM3/4/21
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages