将联系人页面添加到网页时遇到问题。我正在使用Flask来做到这一点。我不明白的部分是这样的:
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = '''[email protected]<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");
l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';
r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;
s+=String.fromCharCode(c);}s=document.createTextNode(s);
l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>]'''
app.config["MAIL_PASSWORD"] = 'password'
和
msg = Message(form.subject.data, sender='''[email protected]<script
type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");
l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';
r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;
s+=String.fromCharCode(c);}s=document.createTextNode(s);
l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>', recipients=['[email protected]<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");
l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';
r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;
s+=String.fromCharCode(c);}s=document.createTextNode(s);
l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>]''')
请说明我应该在代码中的以下位置放置哪个电子邮件地址,我应该在哪里添加我的电子邮件ID?另一个应该是什么。我没有自己的域名。
app.config["MAIL_USERNAME"] = '''[email protected]
app.config["MAIL_PASSWORD"] = 'password'
msg = Message(form.subject.data, sender='''[email protected]
recipients=['[email protected] . .
该教程似乎有些复杂。不知道为什么需要所有Javascript。这是我测试过的对我有用的东西:
gmail的配置设置应类似于:
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = '[email protected]'
app.config['MAIL_PASSWORD'] = 'password'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
在上面的代码中,将替换为app.config['MAIL_USERNAME']
您的实际Gmail地址。密码相同。使用此设置,电子邮件将从您的gmail帐户发送到收件人。上面所有这些信息均适用于发件人,即您的gmail帐户。
然后,要发送电子邮件,只需执行以下操作
msg = Message(subject,sender="[email protected]",recipients=['[email protected]','[email protected]'])
msg.body = "test email"
mail.send(msg)
在上面的代码中,将recipient
s替换为要将电子邮件发送给的人。收件人是一个列表。因此,您可以根据需要输入1个或多个电子邮件地址。
最后,使用上述2,flask-mail将把来自[email protected](即您)的电子邮件发送到user1 @ gmail.com,user2 @ gmail.com等(即接收者)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句