Django Неполный ответ, полученный от приложения при использовании функции sendmail () - PullRequest
0 голосов
/ 17 марта 2019

Я создал приложение на Django 2.0 и развернул его на pythonanywhere.com.Поскольку хостинг Pythonanywhere.com не имеет SMTP-сервера, я использовал внешний сервер (использовался SMPT-сервер hostiq.com, где размещены другие веб-сайты) для отправки сообщений с использованием представлений.Все работало нормально, кроме цены:)

Поэтому я переместил приложение на хостинг reg.ru (потому что оно дешевое и имеет SMTP-сервер).Веб-приложение работает нормально, кроме ссылок, которые отправляют письма.Все функции veiws, которые используют отправку писем, дают сбой и выдают ошибку «Неполный ответ получен из приложения».Вы можете проверить это самостоятельно, перейдя по ссылке: http://www.tajadventures.com/contact-us/

Дополнительная информация, которая может быть полезна для решения проблемы:

1) У меня есть два приложения в общем хостинге..RU.2) Я использую виртуальную среду на сервере;3) Служба поддержки говорит, что использование PROXY (например, Работа с django: настройка прокси ) НЕ РАЗРЕШЕНО на виртуальном хостинге.4) Это то, что говорит файл журнала (отправленный службой поддержки):

open("/opt/openssl/openssl11/cert.pem", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/opt/openssl/openssl11/certs/6a909d98.0", 0x7ffd3f0aebb0) = -1 ENOENT (No such file or directory)
stat("/opt/openssl/openssl11/certs/4a6481c9.0", 0x7ffd3f0aebb0) = -1 ENOENT (No such file or directory)
stat("/opt/openssl/openssl11/certs/4a6481c9.0", 0x7ffd3f0aebb0) = -1 ENOENT (No such file or directory)

При попытке подключения через порт 465 выдает следующее сообщение об ошибке:

ioctl(12, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b0240) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(12, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b01c0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b0870) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b07f0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b0ea0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b0e20) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b14d0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b1450) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b1b00) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b1a80) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b2130) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b20b0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b2760) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b26e0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b2d90) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b2d10) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b33c0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(7, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffd3f0b3340) = -1 ENOTTY (Inappropriate ioctl for device)

После чего скриптзаканчивается следующими ошибками:

write(2, "[ pid=446821, time=2019-03-15 05:51:32,197 ]: WSGI application raised an exception!\nTraceback (most recent call last):\n  File \"/opt/python/python-3.7.0/lib/python3.7/urllib/request.py\", line 1317, in do_open\n    encode_chunked=req.has_header('Transfer-encoding'))\n  File \"/opt/python/python-3.7.0/lib/python3.7/http/client.py\", line 1229, in request\n    self._send_request(method, url, body, headers, encode_chunked)\n  File \"/opt/python/python-3.7.0/lib/python3.7/http/client.py\", line 1275, in _send_request\n    self.endheaders(body, encode_chunked=encode_chunked)\n  File \"/opt/python/python-3.7.0/lib/python3.7/http/client.py\", line 1224, in endheaders\n    self._send_output(message_body, encode_chunked=encode_chunked)\n  File \"/opt/python/python-3.7.0/lib/python3.7/http/client.py\", line 1016, in _send_output\n    self.send(msg)\n  File \"/opt/python/python-3.7.0/lib/python3.7/http/client.py\", line 956, in send\n    self.connect()\n  File \"/opt/python/python-3.7.0/lib/python3.7/http/client.py\", line 1392, in connect\n    server_hostname=server_hostname)\n  File \"/opt/python/python-3.7.0/lib/python3.7/ssl.py\", line 412, in wrap_socket\n    session=session\n  File \"/opt/python/python-3.7.0/lib/python3.7/ssl.py\", line 850, in _create\n    self.do_handshake()\n  File \"/opt/python/python-3.7.0/lib/python3.7/ssl.py\", line 1108, in do_handshake\n    self._sslobj.do_handshake()\nssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/var/www/u0673882/data/taj/lib/python3.7/site-packages/django/core/handlers/exception.py\", line 35, in inner\n    response = get_response(request)\n  File \"/var/www/u0673882/data/taj/lib/python3.7/site-packages/django/core/handlers/base.py\", line 128, in _get_response\n    response = self.process_exception_by_middleware(e, request)\n  File \"/var/www/u0673882/data/taj/lib/python3.7/site-packages/django/core/handlers/base"..., 13113) = 13113
write(2, "\n", 1)                       = 1
shutdown(11, SHUT_WR)                   = 0

5) Приложение отлично работает на другом сервере и локальном компьютере.

6) журналы

[Wed Mar 13 19:23:39 2019] [error] [client 217.11.191.130] File does not exist: /var/www/u0673882/data/www/tajadventures.com/b-dropdown.78b8a4cc60332c97c45cdca66a52b299.png, referer: http://www.tajadventures.com/hosting_static_parking.css
[Wed Mar 13 19:25:27 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 19:32:39 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:11:45 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:12:27 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:12:28 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:14:33 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:18:00 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:22:35 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:22:45 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:25:39 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:25:42 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:26:27 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:26:29 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:28:00 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:28:03 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:28:07 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:28:08 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:28:08 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:28:09 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:29:30 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:29:33 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:30:24 2019] [error] [client 217.11.191.130] File does not exist: /var/www/u0673882/data/www/tajadventures.com/b-dropdown.78b8a4cc60332c97c45cdca66a52b299.png, referer: http://www.tajadventures.com/hosting_static_parking.css
[Wed Mar 13 20:30:57 2019] [error] [client 217.11.191.130] File does not exist: /var/www/u0673882/data/www/tajadventures.com/b-dropdown.78b8a4cc60332c97c45cdca66a52b299.png, referer: http://www.tajadventures.com/hosting_static_parking.css
[Wed Mar 13 20:31:20 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
[Wed Mar 13 20:34:40 2019] [error] [client 217.11.191.130] Directory index forbidden by Options directive: /var/www/u0673882/data/www/tajadventures.com/
2019/03/13 23:24:31 [warn] 376904#0: *12310753 upstream server temporarily disabled while reading response header from upstream, client: 54.165.59.7, server: tajadventures.com, request: "GET /blog/1/we-have-released-our-website/ HTTP/1.0", upstream: "http://127.0.0.1:8080/blog/1/we-have-released-our-website/", host: "www.tajadventures.com"
2019/03/13 23:24:35 [warn] 376901#0: *12310776 upstream server temporarily disabled while reading response header from upstream, client: 54.165.59.7, server: tajadventures.com, request: "GET /cars/1/toyota/ HTTP/1.0", upstream: "http://127.0.0.1:8080/cars/1/toyota/", host: "www.tajadventures.com"
2019/03/14 02:31:31 [warn] 90382#0: *12372200 upstream server temporarily disabled while reading response header from upstream, client: 66.249.70.11, server: tajadventures.com, request: "GET /tours/2/dushanbe-city-tour/ HTTP/1.1", upstream: "http://127.0.0.1:8080/tours/2/dushanbe-city-tour/", host: "www.tajadventures.com"
2019/03/14 02:38:43 [warn] 90383#0: *12378817 upstream server temporarily disabled while reading response header from upstream, client: 66.249.70.5, server: tajadventures.com, request: "GET /tours/3/trekking-to-the-lake-sarez/ HTTP/1.1", upstream: "http://127.0.0.1:8080/tours/3/trekking-to-the-lake-sarez/", host: "www.tajadventures.com"
[Thu Mar 14 16:59:31 2019] [error] [client 79.170.191.3] ModSecurity: Warning. Matched phrase "m.js" at RESPONSE_BODY. [file "/etc/httpd/mod_security/trustwave_rules.conf"] [line "2977"] [id "2500005"] [rev "11272018"] [msg "SLR: Bomonero - Crypto-Mining Activity"] [severity "CRITICAL"] [tag "attack-crypto mining"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "https://www.trustwave.com/Resources/Trustwave-Blog/All-the-Ways-Cybercriminals-Are-Exploiting-the-Cryptocurrency-Boom/"] [hostname "www.tajadventures.com"] [uri "/admin/tours/tour/add/"] [unique_id "XIpeQx8fxgQABOQbpd8AAAEQ"]

Есть ли способисправить эту ошибку?Спасибо заранее за ваше время.

1 Ответ

0 голосов
/ 18 марта 2019

Итак, решение проблемы в моем случае заключалось в удалении Google ReCaptcha из функции просмотра.Мои текущие настройки выглядят следующим образом:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = False
EMAIL_HOST = 'server229.hosting.reg.ru'
EMAIL_PORT = 587
EMAIL_HOST_USER =  'info@domain.com'
EMAIL_HOST_PASSWORD = '********'

Но я думаю, что эта ошибка имеет много причин, например, доступ к URL, который не существует, и т. Д.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...