我试图使用preppy来模拟一些电子邮件消息,但它会插入一个前导空白行,这会导致SMTP将所有内容视为邮件正文而不是标题。在独立测试中,我使用以下python代码:
import preppy
premsg = preppy.getModule('email.prep')
print "========================================="
print premsg.get("sender@example.com", "recipient@example,com", "Message Subject", "https://followthislink.com/qwertyuiopp")
print "========================================="
此模板存储在email.prep
中{{def(prepToAddr, prepFromAddr, prepSubject, prepLink)}}
To: {{prepToAddr}}
From: "{{prepFromAddr}}
Subject: {{prepSubject}}
Click this link to confirm your email address: {{prepLink}}
运行时看起来像这样:
(email)tahaan@Komputer:~/Projects/email$ python prep1.py
=========================================
To: sender@example.com
From: "recipient@example,com
Subject: Message Subject
Click this link to confirm your email address: https://followthislink.com/qwertyuiopp
=========================================
(email)tahaan@Komputer:~/Projects/email$
我是否应该删除前导空行并使用它,或者是否有一些我应该做的不同以使输出正确?
答案 0 :(得分:0)
要做到这一点,你需要更改模板以消除{{def()}}末尾的eol,即
{{def(prepToAddr, prepFromAddr, prepSubject, prepLink)}}To: {{prepToAddr}}
From: "{{prepFromAddr}}
Subject: {{prepSubject}}
Click this link to confirm your email address: {{prepLink}}
要消除eol,你需要一个没有eol的编辑器,参见例如Vim no end of line on last line or eof