Найти - Пользователи
Полная версия: smtp_small_question
Начало » Python для новичков » smtp_small_question
1
avdoshkin
def syslog():
f=open('/var/log/dlink.log')
for line in f.readlines():
if ‘LBD’ in line:
lbd = line.rstrip()
mail(lbd)

f1=open('/var/log/cisco.log')
for line1 in f1.readlines():
if ‘LBD’ in line1:
lbd = line1.rstrip()
mail(lbd)


def mail(lbd):
subject = ‘D_LOOP’
fromaddr = “root@alpha”
toaddrs = “igor@alpha”.split()
msg = (“From: %s\r\nTo: %s\r\nSubject: %s\r\n” % (fromaddr, “, ”.join(toaddrs), subject))
msg = msg + lbd
server = smtplib.SMTP('10.0.9.251')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()

syslog()
При таком коде письма отправляться по строчно, а нужно сформировать в одно массив и отправить один письмом.
Viper
def syslog():
f=open('/var/log/dlink.log')
ldb = ''
for line in f.readlines():
if 'LBD' in line:
lbd += line.rstrip()
mail(lbd)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB