smtplib发送空白正文有问题,即使该值打印到控制台就好了。
父方法:
recipient = 'dummied@dummied.com'
text = 'Subject: Employee Departure Notification.\n%s has left Redcated. Their termination is effective %s.' % (employee_name, text)
print('SMTP text: ', text)
message = smtpObj.sendmail(config['Email']['username'], recipient, text)
这部分代码可以正常工作:
if
i['request_variables'][4]['value'] == 'Immediately':
text = 'their termination is effective immediately'
但不能使用以下内容,虽然它会向控制台打印正确的逻辑(空白正文但电子邮件发送否则)
last_day_long = datetime.strptime(last_day, '%Y-%m-%d') + timedelta(hours=17)
last_day = str(last_day_long)
text = 'their termination is effective %s at 5:00pm' % last_day
print('Last day value before email: ', last_day)
请忽略我糟糕的代码和格式,提前感谢任何帮助!
答案 0 :(得分:0)
解决了我自己的问题 - 需要两次换行而不是一次来自主题 - >标题 - >身体让最后一个片段起作用。不知道为什么它在第二个区块中起作用,但我会接受它。