使用// in the makefile
foo-%: $(foreach member,$(shell cat %),bar-$(member))
和python
将电子邮件发送到我的smtplib
帐户。
mail.google.com
服务总是建议我翻译成电子邮件。语言建议很奇怪。我想完全摆脱翻译建议。
从文件中读取电子邮件。文件内容为俄语。第一行是邮件主题。剩下的就是消息正文。
mail.google.com
从文件文本获取主题行和正文:
fmsg = io.open(FILE_MSG, mode="r", encoding="utf-8")
HTML消息部分:
s = fmsg.read()
s = s.split('\n',1)
SUBJECT = s[0]
BODY_TEXT = s[1]
接下来,发送消息:
BODY_HTML = """<html lang="ru">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="google" content="notranslate" />
<style>
div {padding-top:12pt;}
</style>
</head>
<body>
<div><b>---</b></div>
<section>
<h1>Мое имя</h1>
<address>
<div><a href="tel:+380_____">+380_____</a></div>
<div><a href="skype:_____">live:_____</a>
</div>
<div><a href="mailto:_____@gmail.com">_____@gmail.com</a>
</div>
<address>
</section>
</body>
</html>
"""
问题是,如何向msg = MIMEMultipart('mixed')
msg['Subject'] = SUBJECT
msg['From'] = '"{0}" <{1}>'.format(Header(SENDERNAME, 'utf-8'),SENDER)
msg['To'] = RECIPIENT
part1 = MIMEText(BODY_TEXT, 'plain', 'utf-8')
part2 = MIMEText(BODY_HTML, 'html', 'utf-8')
msg.attach(part1)
msg.attach(part2)
server = smtplib.SMTP(HOST, PORT)
server.ehlo()
server.starttls()
#stmplib docs recommend calling ehlo() before & after starttls()
server.ehlo()
server.login(USERNAME_SMTP, PASSWORD_SMTP)
server.sendmail(SENDER, RECIPIENT, msg.as_string())
server.close()
服务提示不建议翻译为我的电子邮件?