{"id":219,"date":"2021-01-04T10:24:21","date_gmt":"2021-01-04T04:24:21","guid":{"rendered":"http:\/\/www.jichangqing.net\/wordpress\/?p=219"},"modified":"2021-01-04T12:37:07","modified_gmt":"2021-01-04T06:37:07","slug":"219","status":"publish","type":"post","link":"http:\/\/www.jichangqing.net\/wordpress\/?p=219","title":{"rendered":"django \u8bbe\u7f6eQQ mail \u53d1\u90ae\u4ef6 SSL: WRONG_VERSION_NUMBER \u9519\u8bef\u89e3\u51b3"},"content":{"rendered":"<p>django by exapmple \u539f\u4e66\u7b2c\u4e8c\u7ae0\u7528\u7684gmail\u53d1\u90ae\u4ef6, \u56fd\u5185\u8bbf\u95ee\u4e0d\u4e86gmail\u6539\u6210qqmail<br \/>\n===<br \/>\ndjango \u8bbe\u7f6eQQ\u90ae\u7bb1 \u53d1\u90ae\u4ef6,\u63d0\u793a\u9519\u8bef:<\/p>\n<pre><span style=\"color: #969896;\">\r\nFile \"d:\\python39\\lib\\ssl.py\", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1122)\r\n<\/span><\/pre>\n<p>\u89e3\u51b3:<\/p>\n<p>===<\/p>\n<p>\u7b2c\u4e00\u6b65: \u767b\u5f55QQ\u90ae\u7bb1: \u9876\u90e8 \u8bbe\u7f6e &#8211; \u90ae\u7bb1\u8bbe\u7f6e &#8211; \u8d26\u6237 -POP3\/IMAP\/SMTP\/Exchange\/CardDAV\/CalDAV\u670d\u52a1<\/p>\n<div class=\"settingPop_item_cnt\" style=\"color: #000000;\">IMAP\/SMTP\u670d\u52a1 \u53f3\u4fa7\u70b9\u51fb\u5f00\u542f #\u6211\u4e00\u5f00\u59cb\u9009\u4e86pop3\u90a3\u4e2a\u6ca1\u901a\u8fc7, \u540e\u6765\u9009\u4e86IMAP\u8fd9\u4e2a\u901a\u8fc7\u4e86.<\/div>\n<div class=\"settingPop_item_cnt\" style=\"color: #000000;\"><\/div>\n<div class=\"settingPop_item_cnt\" style=\"color: #000000;\">\u6309\u63d0\u793a\u53d1\u77ed\u4fe1<\/div>\n<div class=\"settingPop_item_cnt\" style=\"color: #000000;\"><\/div>\n<div class=\"settingPop_item_cnt\" style=\"color: #000000;\">\u5982\u56fe\u5f97\u5230\u6388\u6743\u7801:<\/div>\n<div class=\"settingPop_item_cnt\" style=\"color: #000000;\"><a href=\"http:\/\/www.jichangqing.net\/wordpress\/wp-content\/uploads\/2021\/01\/20210104121706.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-220\" src=\"http:\/\/www.jichangqing.net\/wordpress\/wp-content\/uploads\/2021\/01\/20210104121706.png\" alt=\"20210104121706\" width=\"889\" height=\"502\" srcset=\"http:\/\/www.jichangqing.net\/wordpress\/wp-content\/uploads\/2021\/01\/20210104121706.png 889w, http:\/\/www.jichangqing.net\/wordpress\/wp-content\/uploads\/2021\/01\/20210104121706-300x169.png 300w\" sizes=\"auto, (max-width: 889px) 100vw, 889px\" \/><\/a><\/div>\n<div class=\"settingPop_item_cnt\" style=\"color: #000000;\">===<\/div>\n<p>\u7b2c\u4e8c\u6b65, \u5728\u5e94\u7528\u7684setting.py\u4e2d\u52a0\u5165\u4ee3\u7801:<\/p>\n<pre><span style=\"color: #969896;\"># send email\r\n<\/span>EMAIL_BACKEND <span style=\"color: #a71d5d;\">= <\/span><span style=\"font-weight: bold; color: #008080;\">'django.core.mail.backends.smtp.EmailBackend'\r\n<\/span>EMAIL_HOST <span style=\"color: #a71d5d;\">= <\/span><span style=\"font-weight: bold; color: #008080;\">'smtp.qq.com'\r\n<\/span>EMAIL_HOST_USER <span style=\"color: #a71d5d;\">= <\/span><span style=\"font-weight: bold; color: #008080;\">'XXX@qq.com' #\u90ae\u7bb1\u8d26\u53f7\r\n<\/span>EMAIL_HOST_PASSWORD <span style=\"color: #a71d5d;\">= <\/span><span style=\"font-weight: bold; color: #008080;\">'XXXXXXX' #\u6ce8\u610f\u8fd9\u4e2a\u4e0d\u662f\u90ae\u7bb1\u767b\u5f55\u5bc6\u7801, \u662f\u521a\u624d\u53d1\u77ed\u4fe1\u540e\u5f97\u5230\u7684\u6388\u6743\u7801\r\n<\/span>EMAIL_PORT <span style=\"color: #a71d5d;\">= <\/span><span style=\"color: #0086b3;\">25 #\u7528465\u548c587\u6ca1\u8fc7, \u6309\u7f51\u4e0a\u653b\u7565\u7528\u4e8625\u901a\u8fc7\u4e86.\r\n<\/span>EMAIL_USE_TLS <span style=\"color: #a71d5d;\">= True\r\n<\/span>EMAIL_USE_SSL <span style=\"color: #a71d5d;\">= False #\u7f51\u4e0a\u653b\u7565\u7528\u7684\u662fTLS, \u6309QQ\u90ae\u7bb1\u5e2e\u52a9\u4e2d\u5e94\u8be5\u7528SSL\r\n<\/span>DEFAULT_FROM_EMAIL <span style=\"color: #a71d5d;\">= <\/span><span style=\"font-weight: bold; color: #008080;\">'XXXX@qq.com' #\u8fd9\u53e5\u5fc5\u9700\u8981\u52a0\u4e0a, \u4f60\u7684QQ\u90ae\u7bb1<\/span><\/pre>\n<p>\u7b2c\u4e09\u6b65\u5728shell\u4e2d\u6d4b\u8bd5<\/p>\n<pre><span style=\"color: #000000;\">py manage.py shell\r\n<\/span><\/pre>\n<pre><span style=\"color: #969896;\"><code class=\"python keyword\" style=\"color: #0000ff !important;\">from<\/code><span style=\"color: #000000;\">\u00a0<\/span><code class=\"python plain\" style=\"color: #000000;\">django.core.mail\u00a0<\/code><code class=\"python keyword\" style=\"color: #0000ff !important;\">import<\/code><span style=\"color: #000000;\">\u00a0<\/span><code class=\"python plain\" style=\"color: #000000;\">send_mail<\/code><\/span>\r\n\r\nsend_mail(\"learn django\", \"step by step\", \"XXX@qq.com\",['XXX@qq.com'], fail_silently=False)\r\n<\/pre>\n<p>\u5982\u679c\u53cd\u9988\u4e3a1\u5c31\u901a\u8fc7\u4e86, \u67e5\u6536\u90ae\u4ef6\u5230\u8fbe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>django by exapmple \u539f\u4e66\u7b2c\u4e8c\u7ae0\u7528\u7684gmail\u53d1\u90ae\u4ef6, \u56fd\u5185\u8bbf\u95ee\u4e0d\u4e86gmail\u6539\u6210qqmail === django \u8bbe\u7f6eQQ\u90ae\u7bb1 \u53d1\u90ae\u4ef6,\u63d0\u793a\u9519\u8bef: File &#8220;d:\\python39\\lib\\ssl.py&#8221;, line  &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,1],"tags":[],"class_list":["post-219","post","type-post","status-publish","format-standard","hentry","category-django","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=219"}],"version-history":[{"count":5,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/219\/revisions"}],"predecessor-version":[{"id":227,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/219\/revisions\/227"}],"wp:attachment":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}