Here's a little Script I copied from some Example Sites and added some Code. It sends an E-Mail with the attached Config DB.
It's provided as it is and it works for me. So as always, no warranties. Perhaps it will be useful for someone.
It's provided as it is and it works for me. So as always, no warranties. Perhaps it will be useful for someone.
Code:
#!/usr/bin/env python import sys import smtplib import time from email.mime.text import MIMEText from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart from email.MIMEBase import MIMEBase from email import Encoders HOSTNAME = 'freenas.local' SERVER = 'your.mailserver.local' FROM = 'root@' + HOSTNAME TO = 'your_mail@localdomain' SUBJECT = 'Config DB of ' + HOSTNAME TEXT = 'The Config DB is from ' + time.asctime() FILENAME = '/data/freenas-v1.db' # msg = MIMEMultipart() msg['Subject'] = SUBJECT msg['From'] = FROM msg['To'] = TO # part0 = MIMEText(TEXT, 'plain') # part1 = MIMEBase('application', "octet-stream") fp = open(FILENAME, 'rb') part1.set_payload( fp.read() ) fp.close() Encoders.encode_base64(part1) part1.add_header('Content-Disposition', 'attachment; filename="%s"' % FILENAME) # msg.attach(part0) msg.attach(part1) # s = smtplib.SMTP(SERVER) s.sendmail(FROM, TO, msg.as_string()) s.quit()