Django使用sendmail()函数从应用程序收到不完整的响应

问题描述 投票:0回答:1

我在Django 2.0上构建了一个应用程序并部署到pythonanywhere.com。由于Pythonanywhere.com托管没有SMTP服务器,我使用外部服务器(使用hostiq.com SMPT服务器,我托管其他网站)使用视图发送消息。一切都很好,除了价格:)

所以我把应用程序移动到reg.ru主机(因为它很便宜并且有SMTP服务器)。 Web应用程序工作正常,但发送邮件的链接除外。使用发送邮件的所有veiws功能,失败并给出错误“从应用程序收到不完整的响应”。您可以通过以下链接自行测试:http://www.tajadventures.com/contact-us/

可能有助于解决问题的更多信息:

1)我在共享主机reg.ru中有两个应用程序。 2)我在服务器上使用虚拟环境; 3)客户支持表示在共享主机中不允许使用PROXY(如此Working with django : Proxy setup)。 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"]

有没有办法解决这个错误?谢谢你的时间。

python django django-views smtp
1个回答
0
投票

所以,我的问题的解决方案是从我的视图功能中删除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 =  '[email protected]'
EMAIL_HOST_PASSWORD = '********'

但我认为这个错误有很多原因,例如访问不存在的url等。

© www.soinside.com 2019 - 2024. All rights reserved.