Save a temporary file in case sending fails

This commit is contained in:
Andreas Moog 2011-11-28 20:50:28 +01:00
parent d9c00752c0
commit 10e9b18ca7

View File

@ -162,6 +162,16 @@ Content-Type: text/plain; charset=UTF-8
print 'The final report is:\n%s' % mail
confirmation_prompt()
# save mail in temporary file
f=open("/tmp/requestsync-" + srcpkg,"w")
f.write(mail)
f.close()
print '''
The e-mail has been saved in %s and will be deleted
after succesful transmission
''' % f.name
# connect to the server
while True:
try:
@ -192,6 +202,10 @@ Content-Type: text/plain; charset=UTF-8
s.quit()
return
try:
s.sendmail(myemailaddr, to, mail.encode('utf-8'))
s.quit()
os.remove(f.name)
Logger.normal('Sync request mailed.')
except:
Logger.error('Unknown error while sending the mail.')