Have you looked at the documentation:
http://doc.scrapy.org/en/latest/topics/email.html
The main use of the documentation
from scrapy.mail import MailSender
mailer = MailSender()
mailer.send(to=["someone@example.com"], subject="Some subject", body="Some body", cc=["another@example.com"])
You can also implement something custom yourself. For example, if you want to use gmail:
def send_mail(self, message, title):
print "Sending mail..........."
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
gmailUser = 'mail_you_send_from@gmail.com'
gmailPassword = 'password'
recipient = 'mail_to_send_to'
msg = MIMEMultipart()
msg['From'] = gmailUser
msg['To'] = recipient
msg['Subject'] = title
msg.attach(MIMEText(message))
mailServer = smtplib.SMTP('smtp.gmail.com', 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(gmailUser, gmailPassword)
mailServer.sendmail(gmailUser, recipient, msg.as_string())
mailServer.close()
print "Mail sent"
and just name it like this:
send_mail("some message", "Scraper Report")
source
share