[英]Getting error while sending email by using Streamsets
i am trying to send an email by using StreamSets. 我试图通过使用StreamSets发送电子邮件。
for this, i am using Directory as Source(list of receipts in the text file) and 为此,我使用目录作为源(文本文件中的收据列表),并且
Jython Evaluator for Processing and trash for Destination(for testing only). 用于处理的Jython评估程序和用于目标的垃圾箱(仅用于测试)。
when i run pipeline, running without any error. 当我运行管道时,运行没有任何错误。 but getting error mail to my sender_email like this:
但是像这样将错误邮件发送到我的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.
Here is my sample code: 这是我的示例代码:
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))
You're seeing this because you're using the record object as the email address - com.streamsets.pipeline.stage.processor.scripting.ScriptRecord@3ea57368
is the string value of a record instance. 您之所以会看到此信息,是因为您使用记录对象作为电子邮件地址
com.streamsets.pipeline.stage.processor.scripting.ScriptRecord@3ea57368
是记录实例的字符串值。
If you're using text data format in the Directory origin, then you can use record.value['text']
instead of record
: 如果您在Directory原点中使用文本数据格式,则可以使用
record.value['text']
代替record
:
mailserver.sendmail('sateesh.karuturi9@gmail.com', record.value['text'], msg.as_string())
If you're using a different data format (delimited, JSON etc), use preview to figure out which field the email address is in, and reference it the same way. 如果您使用其他数据格式(定界,JSON等),请使用预览来确定电子邮件地址位于哪个字段,并以相同的方式引用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.