I send mail through smtp.gmail.com, and the fact is that on the local work computer everything is fine, the data from the form goes and is written to the database, and a message is sent to the email address sent to the email address sent to the user who specified his email address. The whole thing as I understand it in the configuration of the server itself nginx and uwsgi. Previously, the Cherokee Web Server was used on this server and, accordingly, messages were sent to the mail as logs when errors occurred, and I did not recover the mail after switching to nginx + uwsgi when I posted a new project requiring notifications to be sent to users. For sending earlier and now google mail is used, some of the settings from settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' DEFAULT_FROM_EMAIL = 'site@gmail.com' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'site@gmail.com' EMAIL_HOST_PASSWORD = '123456' EMAIL_PORT = 587 

And as I wrote messages from the local server for developers, my desktop computers are sent and received normally, the combat server is gone. Log nginx access.log:

 xx.xx.xxx.xxx - - [13/Oct/2016:20:15:59 +0300] "GET / HTTP/1.1" 200 12659 "http://site.com.ua/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.27$3.0.2785.143 Safari/537.36" xx.xx.xxx.xxx - - [13/Oct/2016:20:17:05 +0300] "POST /order/ HTTP/1.1" 500 38 "http://site.com.ua/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.$me/53.0.2785.143 Safari/537.36" 

in error.log writes nothing.

Installed on the server:

 Ubuntu 14.04.5 LTS 

nginx has this configuration:

 nginx version: nginx/1.4.6 (Ubuntu) built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module 

uwsgi version:

  2.0.13.1 

uwsgi configuration from project:

 [uwsgi] project = site base = /home/site chdir = %(base)/site/%(project) home = /env/site module = project.wsgi:application master = true processes = 5 pidfile = %(base)/site/%(project)/site.pid socket = %(base)/site/%(project)/site.sock chmod-socket = 664 vacuum = true 

configuration with the nginx project:

 server { listen *:80; listen [::]:80; server_name www.site.com.ua; rewrite ^(.*)$ http://site.com.ua$1 permanent; } server { listen *:80; listen [::]:80; server_name site.com.ua; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/site/site/site/project; access_log off; expires 3w; # add_header Cache-Control "max-age=1209600"; add_header Cache-Control public; } location /media/ { root /home/site/site/site/project; access_log off; expires 12w; # add_header Cache-Control "max-age=5258000"; add_header Cache-Control public; } location / { include uwsgi_params; uwsgi_pass unix:/home/site/site/site/site.sock; } } 

In the general configuration of /etc/nginx/nginx.conf, the only thing that I changed was:

 gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_min_length 256; # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-fon$ 

I also noticed this section in nginx.conf:

 #mail { # # See sample authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # # auth_http localhost/auth.php; # # pop3_capabilities "TOP" "USER"; # # imap_capabilities "IMAP4rev1" "UIDPLUS"; # # server { # listen localhost:110; # protocol pop3; # proxy on; # } # # server { # listen localhost:143; # protocol imap; # proxy on; # } #} 

I think that there is a problem in it and if it is set up, then everything will be solved. Found the same on the off. Site http://nginx.org/ru/docs/mail/ngx_mail_core_module.html manual, but it was not possible to configure the sending of mail.

I also post the separate parts of the source of the site:

settings.py:

 """ Django settings for project project. Generated by 'django-admin startproject' using Django 1.10.2. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os from local_settings import * # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'lgdgl;dgl;keks;lfjjtd;fldgl;;gldgfsfsgldgdlgdlp[gdgdgdgd' # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'solo', 'nested_admin', 'project', 'main', 'ckeditor', 'ckeditor_uploader', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', # 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'project.wsgi.application' # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/1.10/topics/i18n/ LANGUAGE_CODE = 'ru-ru' TIME_ZONE = 'Europe/Kiev' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'project', 'static') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'project', 'media') CKEDITOR_UPLOAD_PATH = "uploads/" CKEDITOR_JQUERY_URL = '/static/design/js/jquery.2.1.1.min.js' CKEDITOR_CONFIGS = { 'default': { 'toolbar': 'full', 'forcePasteAsPlainText': True, } } EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' DEFAULT_FROM_EMAIL = 'site@gmail.com' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'site@gmail.com' EMAIL_HOST_PASSWORD = '123456' EMAIL_PORT = 587 

local_settings.py settings on the server:

 DEBUG = False ALLOWED_HOSTS = ['site.com.ua', 'www.site.com.ua', 'x.xx.xxx.xxx'] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'site', 'USER': 'site', 'PASSWORD': '123456', 'HOST': 'localhost', 'PORT': '', } } 

The view.py part of the URL processing form:

 def order(request): if request.method == 'POST': form = OrderForm(request.POST) if form.is_valid(): form = form.save(commit=False) email = form.order_email if email: name = unicode(form.order_name) email = unicode(email) text = name + u', спасибо, ΠΌΡ‹ Π’Π°ΡˆΡƒ заявку ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ! Наш ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ с Π’Π°ΠΌΠΈ свяТСтся Π² блиТаййшСС врСмя.' msg = EmailMessage(u'Π’Π°ΡˆΠ° заявка принята', text, u'site@gmail.com', [email]) msg.content_subtype = "html" msg.send() form.save() return HttpResponse('ok') 

the forms.py form itself based on the model:

 from django.forms import * from .models import Order class OrderForm(ModelForm): class Meta: model = Order fields = '__all__' 

I ask for help on how to configure and allow sending mail on a remote server in the Django 1.10.2 + nginx 1.4.6 + uwsgi 2.0.13.1 bundle.

If someone already has experience or already examples of working configs, because Google didn’t really bring anything normal, everything is somehow blurry, or unfortunately I don’t have enough experience to understand and set it up myself.

UPD: Checked on the recommendation of Elias in the console, everything went fine from the local worker, I deleted the authorization error on the remote:

 user@localcomp:~$ ssh root@x.xx.xxx.xxx (site)root@ssite:/home/site/site/site# cd /home/site/site/site/ (site)root@ssite:/home/site/site/site# source /env/site/bin/activate (site)root@site:/home/site/site/site# python manage.py shell Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.mail import EmailMessage, send_mail >>> from django.conf import settings >>> text = 'спасибо, ΠΌΡ‹ Π’Π°ΡˆΡƒ заявку ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ! Наш ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ с Π’Π°ΠΌΠΈ свяТСтся Π² блиТаййшСС врСмя.' >>> msg = EmailMessage(u'Π’Π°ΡˆΠ° заявка принята', text, 'site@gmail.com', ['site@ukr.net']) >>> msg.content_subtype = "html" >>> msg.send() Traceback (most recent call last): File "<console>", line 1, in <module> File "/env/site/local/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send return self.get_connection(fail_silently).send_messages([self]) File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages new_conn_created = self.open() File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open self.connection.login(self.username, self.password) File "/usr/lib/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp) SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtN\n5.7.14 V4kwSWno7N6SnUKdMQZ86_3Th2K9Cne4X3e7FN4MQjlmEEaTHwl5Yi3jiT7Vy_DlFjcv2b\n5.7.14 OUh8G4be9qEmbzACnJKgCCWQwtlATsWA4nwbR75upvniJNWo4AMLSyLinB1BuFn8g0a1V2\n5.7.14 G3NUwucq2nJCx2S_9a2NGwj7YhiAeQ7crLfufVJ8vTv9FA8rDV_oAK9BMvmT9S9cqGLRuk\n5.7.14 7O49msgf50imyWx9LXZmRwyPjUutg> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 h36sm4805825ljh.41 - gsmtp') >>> OUh8G4be9qEmbzACnJKgCCWQwtlATsWA4nwbR75upvniJNWo4AMLSyLinB1BuFn8g0a1V2 \ n5.7.14 G3NUwucq2nJCx2S_9a2NGwj7YhiAeQ7crLfufVJ8vTv9FA8rDV_oAK9BMvmT9S9cqGLRuk \ n5.7.14 user@localcomp:~$ ssh root@x.xx.xxx.xxx (site)root@ssite:/home/site/site/site# cd /home/site/site/site/ (site)root@ssite:/home/site/site/site# source /env/site/bin/activate (site)root@site:/home/site/site/site# python manage.py shell Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.mail import EmailMessage, send_mail >>> from django.conf import settings >>> text = 'спасибо, ΠΌΡ‹ Π’Π°ΡˆΡƒ заявку ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ! Наш ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ с Π’Π°ΠΌΠΈ свяТСтся Π² блиТаййшСС врСмя.' >>> msg = EmailMessage(u'Π’Π°ΡˆΠ° заявка принята', text, 'site@gmail.com', ['site@ukr.net']) >>> msg.content_subtype = "html" >>> msg.send() Traceback (most recent call last): File "<console>", line 1, in <module> File "/env/site/local/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send return self.get_connection(fail_silently).send_messages([self]) File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages new_conn_created = self.open() File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open self.connection.login(self.username, self.password) File "/usr/lib/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp) SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtN\n5.7.14 V4kwSWno7N6SnUKdMQZ86_3Th2K9Cne4X3e7FN4MQjlmEEaTHwl5Yi3jiT7Vy_DlFjcv2b\n5.7.14 OUh8G4be9qEmbzACnJKgCCWQwtlATsWA4nwbR75upvniJNWo4AMLSyLinB1BuFn8g0a1V2\n5.7.14 G3NUwucq2nJCx2S_9a2NGwj7YhiAeQ7crLfufVJ8vTv9FA8rDV_oAK9BMvmT9S9cqGLRuk\n5.7.14 7O49msgf50imyWx9LXZmRwyPjUutg> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 h36sm4805825ljh.41 - gsmtp') >>> 

I can not fully understand the error, why smtp.gmail.com does not authorize and does not accept my outgoing letter, please help me figure it out.

  • port through which the mail goes open? - nΓΆrbΓΆrnΓ«n
  • Everything is open in iptables, added the rule iptables -A INPUT -p tcp --dport 587 -j ACCEPT is still an error, but I also checked the sending from the console on the server and added the report to my post, issued an authorization error, but before that with Cherokee Web Server everything was fine, after the transition to nginx and uwsgi is gone. I think it's not about ports, because mail was not received by smtp.gmail.com itself and gave an authorization error, why I don’t understand, I already changed the address encoding to koi8-r, it still did not help. On the local working computer, everything is fine again, though if you change the encoding of the whole body, it comes with a cracker - Nikolay

2 answers 2

Nginx access log says that the error is in the view. Possible problems with the encoding. Need to know the details. Django uses the smtplib standard python library. So you can check sending mail in the python console or django shell.

 ./manage.py shell from django.core.mail import EmailMessage text = u'спасибо, ΠΌΡ‹ Π’Π°ΡˆΡƒ заявку ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ! Наш ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ с Π’Π°ΠΌΠΈ свяТСтся Π² блиТаййшСС врСмя.' msg = EmailMessage(u'Π’Π°ΡˆΠ° заявка принята', text, 'site@gmail.com', ['my_best_email@gmail.com']) msg.content_subtype = "html" msg.send() 
  • Thanks, I did it in the console both on the local and on the server, in general, everything is fine on the local, and on the server I have an authorization error smtp.gmail.com. I tried to change the encoding of email addresses to 'koi8-r', if the message body is crooked, but all this did not help, it is sent and sent to the mail with different encodings from the local one anyway, there is no server at all. I posted an error log at the end of my post, it may be possible to prompt and help to figure out why and what I am doing wrong. Can really in the configuration or my code is not specified because of what the combat server does not work. - Nikolay
  • Possibly blocked access to a specific server. Try here - accounts.google.com/DisplayUnlockCaptcha . - Ilya
  • Thanks, it really worked, but strangely, I also used DisplayUnlockCaptcha and did not help on the old account that was previously used, and with the other one before allowing access to the account with an unreliable application, in general, the settings were both the same and unlocked too, but did not work. And after a couple of days everything worked, probably it was necessary time. - Nikolay

In general, the problem was solved by changing smtp.gmail.com to smtp.mail.ru.

Some settings with settings.py:

 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' DEFAULT_FROM_EMAIL = 'site@mail.ru' EMAIL_HOST = 'smtp.mail.ru' EMAIL_PORT = 2525 EMAIL_HOST_USER = "site@mail.ru" EMAIL_HOST_PASSWORD = "123456" EMAIL_USE_TLS = True 

And the form processing function from views.py:

 def order(request): if request.method == 'POST': form = OrderForm(request.POST) if form.is_valid(): form = form.save(commit=False) email = form.order_email if email: email_sender = DEFAULT_FROM_EMAIL name = form.order_name email = email text = name + ', спасибо, ΠΌΡ‹ Π’Π°ΡˆΡƒ заявку ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ! Наш ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ с Π’Π°ΠΌΠΈ свяТСтся Π² блиТаййшСС врСмя.' msg = EmailMessage('Заявка Π½Π° ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ·ΠΊΡƒ Π³Ρ€ΡƒΠ·Π° ΠΎΡ‚ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ eXimo', text, email_sender, [email]) msg.content_subtype = "html" msg.send() form.save() return HttpResponse('ok') 

But I am still interested in the problem, why mail is not sent from smtp.gmail.com, since it was previously sent when there was a Cherokee Web Server, but when a month earlier it was transferred to nginx + uwsgi smtp.gmail.com refuses to send messages, everything is fine with smtp.mail.ru. On a local work computer with Django 1.10.2 running in debug mode, everything is normally sent via both smtp servers.

The remote VPS server is running on FastVPS, the google email account is also sending from another server on which the Cherokee Web Server is installed and that's all and reports are sent to the mail with errors, and I don’t think this is a google ban. This account is on several servers and I’m still receiving reports with errors from them. Once again I post the error report from the console, maybe someone knows the solution to this problem:

 user@localcomp:~$ ssh root@x.xx.xxx.xxx (site)root@ssite:/home/site/site/site# cd /home/site/site/site/ (site)root@ssite:/home/site/site/site# source /env/site/bin/activate (site)root@site:/home/site/site/site# python manage.py shell Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.mail import EmailMessage, send_mail >>> from django.conf import settings >>> text = 'спасибо, ΠΌΡ‹ Π’Π°ΡˆΡƒ заявку ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ! Наш ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ с Π’Π°ΠΌΠΈ свяТСтся Π² блиТаййшСС врСмя.' >>> msg = EmailMessage(u'Π’Π°ΡˆΠ° заявка принята', text, 'site@gmail.com', ['site@ukr.net']) >>> msg.content_subtype = "html" >>> msg.send() Traceback (most recent call last): File "<console>", line 1, in <module> File "/env/site/local/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send return self.get_connection(fail_silently).send_messages([self]) File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages new_conn_created = self.open() File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open self.connection.login(self.username, self.password) File "/usr/lib/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp) SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtN\n5.7.14 V4kwSWno7N6SnUKdMQZ86_3Th2K9Cne4X3e7FN4MQjlmEEaTHwl5Yi3jiT7Vy_DlFjcv2b\n5.7.14 OUh8G4be9qEmbzACnJKgCCWQwtlATsWA4nwbR75upvniJNWo4AMLSyLinB1BuFn8g0a1V2\n5.7.14 G3NUwucq2nJCx2S_9a2NGwj7YhiAeQ7crLfufVJ8vTv9FA8rDV_oAK9BMvmT9S9cqGLRuk\n5.7.14 7O49msgf50imyWx9LXZmRwyPjUutg> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 h36sm4805825ljh.41 - gsmtp') >>> OUh8G4be9qEmbzACnJKgCCWQwtlATsWA4nwbR75upvniJNWo4AMLSyLinB1BuFn8g0a1V2 \ n5.7.14 G3NUwucq2nJCx2S_9a2NGwj7YhiAeQ7crLfufVJ8vTv9FA8rDV_oAK9BMvmT9S9cqGLRuk \ n5.7.14 user@localcomp:~$ ssh root@x.xx.xxx.xxx (site)root@ssite:/home/site/site/site# cd /home/site/site/site/ (site)root@ssite:/home/site/site/site# source /env/site/bin/activate (site)root@site:/home/site/site/site# python manage.py shell Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.mail import EmailMessage, send_mail >>> from django.conf import settings >>> text = 'спасибо, ΠΌΡ‹ Π’Π°ΡˆΡƒ заявку ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ! Наш ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ с Π’Π°ΠΌΠΈ свяТСтся Π² блиТаййшСС врСмя.' >>> msg = EmailMessage(u'Π’Π°ΡˆΠ° заявка принята', text, 'site@gmail.com', ['site@ukr.net']) >>> msg.content_subtype = "html" >>> msg.send() Traceback (most recent call last): File "<console>", line 1, in <module> File "/env/site/local/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send return self.get_connection(fail_silently).send_messages([self]) File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages new_conn_created = self.open() File "/env/site/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open self.connection.login(self.username, self.password) File "/usr/lib/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp) SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtN\n5.7.14 V4kwSWno7N6SnUKdMQZ86_3Th2K9Cne4X3e7FN4MQjlmEEaTHwl5Yi3jiT7Vy_DlFjcv2b\n5.7.14 OUh8G4be9qEmbzACnJKgCCWQwtlATsWA4nwbR75upvniJNWo4AMLSyLinB1BuFn8g0a1V2\n5.7.14 G3NUwucq2nJCx2S_9a2NGwj7YhiAeQ7crLfufVJ8vTv9FA8rDV_oAK9BMvmT9S9cqGLRuk\n5.7.14 7O49msgf50imyWx9LXZmRwyPjUutg> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 h36sm4805825ljh.41 - gsmtp') >>> 

I would be very grateful for any help, because I would still like to use smtp.gmail.com than from mail.ru