i am trying to send an email by using 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).
when i run pipeline, running without any error. but getting error mail to my sender_email like this:
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('[email protected]', 'password')
mailserver.sendmail('[email protected]',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.If you're using text data format in the Directory origin, then you can use
record.value['text']
instead ofrecord
: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.