应用控制台在使用Flask发送电子邮件时显示大量红线,但没有任何错误。

huangapple go评论71阅读模式
英文:

app console showing alot on redlines without any error when sending email with flask

问题

以下是您要翻译的代码部分:

i have simpel flask app and i want to send email for conformation to user i test it with my email everything works fien but i get alot of redline in my app console i am totaly begginer and i cant analyze what happen here plaese tell me what is this and what can i do

this is my function for sending email :

    @app.route("/confirm", methods=["POST", "GET"])
    @login_required
    def confirm():
        user_email = current_user.email
        token = serializer.dumps(user_email, salt="email-confirm")
        link = url_for("confirm_email", token=token, _external=True)
        msg = Message("Confirm Email", sender=app.config["MAIL_USERNAME"], recipients= [user_email])
        msg.body = render_template("public/email.html", user=current_user, link=link)
        msg.html = render_template("public/email.html", user=current_user, link=link)
        mail.send(msg)
        return render_template("public/index.html", time=time, user=current_user, link=link)

and i get this red lines :

    send: 'ehlo [172.31.128.1]\r\n'
    reply: b'250-smtp.gmail.com at your service, [80.210.8.202]\r\n'
    reply: b'250-SIZE 35882577\r\n'
    reply: b'250-8BITMIME\r\n'
    reply: b'250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n'
    reply: b'250-ENHANCEDSTATUSCODES\r\n'
    reply: b'250-PIPELINING\r\n'
    reply: b'250-CHUNKING\r\n'
    reply: b'250 SMTPUTF8\r\n'
    reply: retcode (250); Msg: b'smtp.gmail.com at your service, [80.210.8.202]\nSIZE 35882577\n8BITMIME\nAUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8'
    send: 'AUTH PLAIN AGZyZXNoLnBvdXJ5YUBnbWFpbC5jb20AeXFubmt6cXF2eWpud3VkZQ==\r\n'
    reply: b'235 2.7.0 Accepted\r\n'
    reply: retcode (235); Msg: b'2.7.0 Accepted'
    send: 'mail FROM:<fresh.pourya@gmail.com> size=3274\r\n'
    reply: b'250 2.1.0 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n'
    reply: retcode (250); Msg: b'2.1.0 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp'
    send: 'rcpt TO:<mr.guitar.clash@gmail.com>\r\n'
    reply: b'250 2.1.5 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n'
    reply: retcode (250); Msg: b'2.1.5 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp'
    send: 'data\r\n'
    reply: b'354 Go ahead q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n'
    reply: retcode (354); Msg: b'Go ahead q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp'
    data: (354, b'Go ahead q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp')
    send: b'Content-Type: multipart/mixed; boundary="===============1820571993399238898=="\r\nMIME-Version: 1.0\r\nSubject: Confirm Email\r\nFrom: fresh.pourya@gmail.com\r\nTo: mr.guitar.clash@gmail.com\r\nDate: Tue, 07 Mar 2023 18:29:08 +0330\r\nMessage-ID: <167820114761.3828.4077954944079907248@DESKTOP-TKGFEBA>\r\n\r\n--===============1820571993399238898==\r\nContent-Type: multipart/alternative;\r\n boundary="===============0785586450470497431=="\r\nMIME-Version: 1.0\r\n\r\n--===============0785586450470497431==\r\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: 7bit\r\n\n<!DOCTYPE html>\n<html lang="en">\n<head>\n    <meta charset="UTF-8">\n    <title>Confirm Email</title>\n    <link href="https://fonts.googleapis.com/css2?family=Anton&family=Dancing+Script:wght@700&family=Mynerve&family=Roboto:wght@500&display=swap" rel="stylesheet">    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">\n    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">\n</head>\n<body>\n    <div class="container-fluid" style="background-color: #666666; padding: 5% 20px 0; margin: 0">\n        <h1 style="font-family: 'Dancing Script', cursive; margin: 0">Favorite Cafe</h1>\n\n    </div>\n    <div class="container-fluid" style="background-color: #6096B4; padding: 5%">\n        <h3 style="margin: 0">Dear FATEMEH mohamadi</h3>\n        <p>click on the link blow to active confirm your email account this link will expire after 24 hours</p>\n        <a href="http://127.0.0.1:5000/confirm-email/Im1yL.g1aXRhci5jbGFzaEBnbWFpbC5jb20i.J0k1dP.gY2UeWWU">Confirm</a>\n\n    </div>\n</body

<details>
<summary>英文:</summary>

i have simpel flask app and i want to send email for conformation to user i test it with my email everything works fien but i get alot of redline in my app console i am totaly begginer and i cant analyze what happen here plaese tell me what is this and what can i do 

this is my function for sending email :

    @app.route(&quot;/confirm&quot;, methods=[&quot;POST&quot;, &quot;GET&quot;])
    @login_required
    def confirm():
        user_email = current_user.email
        token = serializer.dumps(user_email, salt=&quot;email-confirm&quot;)
        link = url_for(&quot;confirm_email&quot;, token=token, _external=True)
        msg = Message(&quot;Confirm Email&quot;, sender=app.config[&quot;MAIL_USERNAME&quot;], recipients= [user_email])
        msg.body = render_template(&quot;public/email.html&quot;, user=current_user, link=link)
        msg.html = render_template(&quot;public/email.html&quot;, user=current_user, link=link)
        mail.send(msg)
        return render_template(&quot;public/index.html&quot;, time=time, user=current_user, link=link)

and i get this red lines :

    send: &#39;ehlo [172.31.128.1]\r\n&#39;
    reply: b&#39;250-smtp.gmail.com at your service, [80.210.8.202]\r\n&#39;
    reply: b&#39;250-SIZE 35882577\r\n&#39;
    reply: b&#39;250-8BITMIME\r\n&#39;
    reply: b&#39;250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n&#39;
    reply: b&#39;250-ENHANCEDSTATUSCODES\r\n&#39;
    reply: b&#39;250-PIPELINING\r\n&#39;
    reply: b&#39;250-CHUNKING\r\n&#39;
    reply: b&#39;250 SMTPUTF8\r\n&#39;
    reply: retcode (250); Msg: b&#39;smtp.gmail.com at your service, [80.210.8.202]\nSIZE 35882577\n8BITMIME\nAUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8&#39;
    send: &#39;AUTH PLAIN AGZyZXNoLnBvdXJ5YUBnbWFpbC5jb20AeXFubmt6cXF2eWpud3VkZQ==\r\n&#39;
    reply: b&#39;235 2.7.0 Accepted\r\n&#39;
    reply: retcode (235); Msg: b&#39;2.7.0 Accepted&#39;
    send: &#39;mail FROM:&lt;fresh.pourya@gmail.com&gt; size=3274\r\n&#39;
    reply: b&#39;250 2.1.0 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n&#39;
    reply: retcode (250); Msg: b&#39;2.1.0 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp&#39;
    send: &#39;rcpt TO:&lt;mr.guitar.clash@gmail.com&gt;\r\n&#39;
    reply: b&#39;250 2.1.5 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n&#39;
    reply: retcode (250); Msg: b&#39;2.1.5 OK q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp&#39;
    send: &#39;data\r\n&#39;
    reply: b&#39;354  Go ahead q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n&#39;
    reply: retcode (354); Msg: b&#39;Go ahead q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp&#39;
    data: (354, b&#39;Go ahead q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp&#39;)
    send: b&#39;Content-Type: multipart/mixed; boundary=&quot;===============1820571993399238898==&quot;\r\nMIME-Version: 1.0\r\nSubject: Confirm Email\r\nFrom: fresh.pourya@gmail.com\r\nTo: mr.guitar.clash@gmail.com\r\nDate: Tue, 07 Mar 2023 18:29:08 +0330\r\nMessage-ID: &lt;167820114761.3828.4077954944079907248@DESKTOP-TKGFEBA&gt;\r\n\r\n--===============1820571993399238898==\r\nContent-Type: multipart/alternative;\r\n boundary=&quot;===============0785586450470497431==&quot;\r\nMIME-Version: 1.0\r\n\r\n--===============0785586450470497431==\r\nContent-Type: text/plain; charset=&quot;utf-8&quot;\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: 7bit\r\n\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;en&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;Confirm Email&lt;/title&gt;\r\n    &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Anton&amp;family=Dancing+Script:wght@700&amp;family=Mynerve&amp;family=Roboto:wght@500&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css&quot;&gt;\r\n    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css&quot; integrity=&quot;sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm&quot; crossorigin=&quot;anonymous&quot;&gt;\r\n\r\n&lt;/head&gt;\r\n&lt;body&gt;\r\n    &lt;div class=&quot;container-fluid&quot; style=&quot;background-color: #666666; padding: 5% 20px 0; margin: 0&quot;&gt;\r\n        &lt;h1 style=&quot;font-family: \&#39;Dancing Script\&#39;, cursive; margin: 0&quot;&gt;Favorite Cafe&lt;/h1&gt;\r\n\r\n    &lt;/div&gt;\r\n    &lt;div class=&quot;container-fluid&quot; style=&quot;background-color: #6096B4; padding: 5%&quot;&gt;\r\n        &lt;h3 style=&quot;margin: 0&quot;&gt;Dear FATEMEH mohamadi&lt;/h3&gt;\r\n        &lt;p&gt;click on the link blow to active confirm your email account this link will expire after 24 hours&lt;/p&gt;\r\n        &lt;a href=&quot;http://127.0.0.1:5000/confirm-email/Im1yLmd1aXRhci5jbGFzaEBnbWFpbC5jb20i.J0k1dPV51jFl1QMzo6tdg3UeWWU&quot;&gt;Confirm&lt;/a&gt;\r\n\r\n    &lt;/div&gt;\r\n&lt;/body&gt;\r\n&lt;/html&gt;\r\n--===============0785586450470497431==\r\nContent-Type: text/html; charset=&quot;utf-8&quot;\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: 7bit\r\n\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;en&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;Confirm Email&lt;/title&gt;\r\n    &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Anton&amp;family=Dancing+Script:wght@700&amp;family=Mynerve&amp;family=Roboto:wght@500&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css&quot;&gt;\r\n    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css&quot; integrity=&quot;sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm&quot; crossorigin=&quot;anonymous&quot;&gt;\r\n\r\n&lt;/head&gt;\r\n&lt;body&gt;\r\n    &lt;div class=&quot;container-fluid&quot; style=&quot;background-color: #666666; padding: 5% 20px 0; margin: 0&quot;&gt;\r\n        &lt;h1 style=&quot;font-family: \&#39;Dancing Script\&#39;, cursive; margin: 0&quot;&gt;Favorite Cafe&lt;/h1&gt;\r\n\r\n    &lt;/div&gt;\r\n    &lt;div class=&quot;container-fluid&quot; style=&quot;background-color: #6096B4; padding: 5%&quot;&gt;\r\n        &lt;h3 style=&quot;margin: 0&quot;&gt;Dear FATEMEH mohamadi&lt;/h3&gt;\r\n        &lt;p&gt;click on the link blow to active confirm your email account this link will expire after 24 hours&lt;/p&gt;\r\n        &lt;a href=&quot;http://127.0.0.1:5000/confirm-email/Im1yLmd1aXRhci5jbGFzaEBnbWFpbC5jb20i.J0k1dPV51jFl1QMzo6tdg3UeWWU&quot;&gt;Confirm&lt;/a&gt;\r\n\r\n    &lt;/div&gt;\r\n&lt;/body&gt;\r\n&lt;/html&gt;\r\n--===============0785586450470497431==--\r\n\r\n--===============1820571993399238898==--\r\n.\r\n&#39;
    reply: b&#39;250 2.0.0 OK  1678201150 q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n&#39;
    reply: retcode (250); Msg: b&#39;2.0.0 OK  1678201150 q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp&#39;
    data: (250, b&#39;2.0.0 OK  1678201150 q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp&#39;)
    send: &#39;quit\r\n&#39;
    reply: b&#39;221 2.0.0 closing connection q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp\r\n&#39;
    reply: retcode (221); Msg: b&#39;2.0.0 closing connection q16-20020adfea10000000b002c559def236sm12683509wrm.57 - gsmtp&#39;
    127.0.0.1 - - [07/Mar/2023 18:29:09] &quot;GET /confirm HTTP/1.1&quot; 200 -




</details>


# 答案1
**得分**: 1

以下是翻译好的部分

"在文档中,MAIL_DEBUG 的默认值实际上是 True,我只是将其更改为 false,然后不再看到这些消息。

将 MAIL_DEBUG 设置为 False"

<details>
<summary>英文:</summary>

t&#39;s actually in the documentation MAIL_DEBUG defualt value is True and i just change it to false and i dont see this messages anymore

Set MAIL_DEBUG = False

</details>



huangapple
  • 本文由 发表于 2023年3月7日 23:00:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663649.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定