Noob,创建了他的第一个动态网页,用户可以在其中输入消息,以及他们的名字和姓氏、电子邮件和电话号码。我最关心我打算通过电子邮件转发的消息以及其他信息(如果提供)。我编写了一个简单的 python 脚本(站点将是 Flask、python 和 HTML),但它在每个输出之间插入了一条不需要的水平线,即
亲爱的鲍勃
留言内容到这里
名
我的目标是让传出消息类似于实际的电子邮件,即如上所示,但没有水平线。我在网上找到了以下大部分代码,这在很大程度上是有效的。我能理解的简单答案优于我不能理解的聪明答案(我是菜鸟)。
def to_mail(first, last, phone, email, User_Complaint, addressed_to):
# E mail account details
my_sending_email = 'testing@gmail.com'
sending_email_password = 'pass'
# set up the SMTP server
s = smtplib.SMTP(host='smtp.gmail.com', port=587)
s.starttls()
s.login(my_sending_email, sending_email_password)
msg = MIMEMultipart()
msg['Subject'] = 'Reporting an Issue With the Courts'
msg['From'] = my_sending_email
msg['To'] = addressed_to
# Body of Email
intro = MIMEText("Dear Leader")
message_contents = MIMEText(User_Complaint)
# use of .attach appears to insert the horizontal line
msg.attach(intro)
msg.attach(message_contents)
# Party's Contact Info to append at bottom of email
msg.attach(MIMEText(first + last))
msg.attach(MIMEText(phone))
msg.attach(MIMEText(email))
s.send_message(msg)
del msg
s.quit()
我只想在邮件正文中生成正常外观的电子邮件内容,即
“尊敬的领导,
我真的很喜欢你的头发。我是你最忠实的粉丝。
(后面的每个传记条目都应该在自己的换行符上,但这会自动将其放在一行上)Stan Lee\n stan@lee.com\n 647-647-1234"