Hello list, I have a function which receives a string and sends it as a body of an email.
It is a part of a program which does certain checks on network infrastructure. When a check fails I append error message to a error_collector list: if self.check_axfr_refused(ip): error_collector.append('%s:%s AXFR test for %s FAILED' % (ns, ip, self.domainname)) At the end I send the alert like this: if len(error_collector) != 0: email_body = str(error_collector) email_alert(email_body) The problem is the resulted email (expectedly) has the alert message as one long string. ['pdns6.ultradns.co.uk.:204.74.115.1 AXFR test for amazon.com FAILED', 'pdns6.ultradns.co.uk.:2610:a1:1017::1 AXFR test for amazon.com FAILED', 'ns4.p31.dynect.net.:204.13.251.31 AXFR test for amazon.com FAILED',...] I tried adding '\n' to end of each string error_collector collects, but then these were simply added to the resulted email. What I want to achieve is that each collected error is shown on a separate line in the email. Any advice will be well appreciated. Here is the email sending function if in interest: def email_alert(message, recipient=DEFAULT_RECIPIENT, subject_prefix=''): ''' Send email alert. ''' # check if we are running in quiet mode if QUIET.lower() == 'yes': return msg = MIMEText(message) msg['From'] = SENDER msg['To'] = recipient msg['Subject'] = subject_prefix + SUBJECT s = smtplib.SMTP(SMTP_SERVER) s.send_message(msg) s.quit() Emil _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor