我正在尝试使用 StreamSets 发送电子邮件。
为此,我使用目录作为源(文本文件中的收据列表)和
用于处理的 Jython 评估器和用于目的地的垃圾(仅用于测试)。
当我运行管道时,运行没有任何错误。但是像这样将错误邮件发送到我的 sender_email:
Your message wasn't delivered to com.streamsets.pipeline.stage.processor.scripting.ScriptRecord@3ea57368 because the domain 3ea57368 couldn't be found. Check for typos or unnecessary spaces and try again.
这是我的示例代码:
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import logging
for record in records:
try:
msg = MIMEMultipart()
msg['Subject'] = 'simple email in python'
message = 'here is the email'
msg.attach(MIMEText(message))
mailserver = smtplib.SMTP('smtp.gmail.com',587)
mailserver.ehlo()
mailserver.starttls()
mailserver.ehlo()
mailserver.login('sateesh.karuturi9@gmail.com', 'password')
mailserver.sendmail('sateesh.karuturi9@gmail.com',record,msg.as_string())
output.write(record)
mailserver.quit()
except Exception as e:
error.write(record, str(e))