在Python中发送到通讯组列表的问题

2024-04-25 02:07:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我每天都会运行一个报告,我试图发送到一个通讯组列表,但是有一个小问题导致了一个大问题,因为它没有被发送到适当的人。如果我试图将报告发送到地址中带有句点的通讯组列表,则报告将不会发送。否则,它发送罚款。在

如果我将报告发送到单个电子邮件,如“myname@domain.com”,它会起作用。在

如果我将报告发送到诸如“ME-EXAMPLE-EAMPLE2@domain.com”这样的通讯组列表,它也可以工作。在

但是,我要发送到的通讯组列表中有句点。一、 E“ME.EXAMPLE.EXAMPLE2@domain.com”,这是行不通的

我唯一能想到的是python在解析句点时遇到了问题。有没有其他人遇到过这个问题或者找到了解决办法?在

def sendEmail(parser):
    email = 'ME.EXAMPLE.EXAMPLE2.ME@gmail.com'
    dailyReportLocation = parser.get('FileLocations','dailyReport')
    yearlyReportLocation = parser.get('FileLocations','yearlyReport')
    blankFile = parser.get('FileLocations','blankEmailContentFile')

    fh = open(blankFile, 'w+')
    fh.close()

    linuxCMD = 'mutt -s "Daily & Yearly Hang Report" -a %s -a %s "%s" < %s ' % (dailyReportLocation,yearlyReportLocation,email,blankFile)

    #print(linuxCMD)
    os.system(linuxCMD)




if __name__ == '__main__':
    c = ConfigurationPreCheck()
    parser = c.run()
    scrubbedFile = scrubPreviousDayReport(parser,getPreviousDayReportName(parser))
    runReport(parser,DAILY_REPORT)
    runReport(parser,YEARLY_REPORT)
    sendEmail(parser)

Tags: comparser列表getexampleemaildomain报告