簡體   English   中英

使用sendmail()函數時,Django從應用程序收到的響應不完整

[英]Django Incomplete response received from application while using sendmail() function

我在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(像這樣使用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"]

有沒有辦法解決這個錯誤? 謝謝你的時間。

因此,就我而言,該問題的解決方案是從我的視圖功能中刪除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等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM