|
From: <di...@us...> - 2011-08-31 13:02:50
|
Revision: 759
http://safekeep.svn.sourceforge.net/safekeep/?rev=759&view=rev
Author: dimi
Date: 2011-08-31 13:02:44 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
Marco Bozzolan <ma...@s1...>
Allow to specify a sender address for the log messages sent via e-mail.
Modified Paths:
--------------
safekeep/trunk/doc/safekeep.conf.txt
safekeep/trunk/safekeep
safekeep/trunk/safekeep.conf
Modified: safekeep/trunk/doc/safekeep.conf.txt
===================================================================
--- safekeep/trunk/doc/safekeep.conf.txt 2011-06-11 16:14:14 UTC (rev 758)
+++ safekeep/trunk/doc/safekeep.conf.txt 2011-08-31 13:02:44 UTC (rev 759)
@@ -31,6 +31,10 @@
If not specified, it defaults to the home directory
of the backup user.
+email.from::
+ The email address to be used as sender when sending the logs.
+ If not specified `safekeep` will use SafeKeep@<hostname fqdn>.
+
email.to::
In addition to writing the session logs
on the standard output, `safekeep` can also send the
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2011-06-11 16:14:14 UTC (rev 758)
+++ safekeep/trunk/safekeep 2011-08-31 13:02:44 UTC (rev 759)
@@ -242,21 +242,23 @@
return None
return out or ''
-def send_notification(email, smtp):
+def send_notification(email_from, email, smtp):
global logbuf
if not logbuf: return
info('Sending email to %s via %s' % (','.join(email), smtp))
- hostname = socket.gethostname()
- msg = 'From: SafeKeep@' + hostname + \
+ hostname = socket.getfqdn()
+ if not email_from:
+ email_from = 'SafeKeep@' + hostname
+ msg = 'From: ' + email_from + \
'\r\nTo: ' + ', '.join(email) + \
'\r\nSubject: SafeKeep results for ' + hostname + \
'\r\n\r\n' + '\r\n'.join(logbuf)
if smtp:
server = smtplib.SMTP(smtp)
- server.sendmail('SafeKeep@' + hostname, email, msg)
+ server.sendmail(email_from, email, msg)
server.quit()
else:
- cmd = ['/usr/sbin/sendmail', '-t']
+ cmd = ['/usr/sbin/sendmail', '-t', '-f', email_from]
call(cmd, stdin=msg)
def is_temp_root(dir):
@@ -1503,6 +1505,8 @@
smtp = props['email.smtp.server']
if 'email.to' in props:
email = props['email.to'].split(',')
+ if 'email.from' in props:
+ email_from = props['email.from']
nice_def = get_int('nice.adjustment')
if nice_def is None: nice_def = 10
nice_srv = get_int('nice.adjustment.server') or nice_def
@@ -1589,7 +1593,7 @@
error('ERROR: %s' % (ex or ''), ex)
if email and not noemail:
- send_notification(email, smtp)
+ send_notification(email_from, email, smtp)
if __name__ == '__main__':
main()
Modified: safekeep/trunk/safekeep.conf
===================================================================
--- safekeep/trunk/safekeep.conf 2011-06-11 16:14:14 UTC (rev 758)
+++ safekeep/trunk/safekeep.conf 2011-08-31 13:02:44 UTC (rev 759)
@@ -33,5 +33,8 @@
# a comma separated list of emails to receive the logs
# ema...@co...,ro...@co...
+# An email address to be used as sender
+# email.from = saf...@co...
+
# a SMTP server to use to deliver email if email.to is non-empty
# email.smtp.server=mail.company.com
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|