Merhabalar,
Sahadan gelen bilgilere göre mail atan bir program yazmaya çalıştım. Tarih ve saat bilgisini değişken olarak girerek mail gönderebiliyorum.
Fakat table kısmındaki ikinci satırın “makine1” olan kısmını db den değişken olarak nasıl atayabilirim.
Çünkü her makine veya problemi sınıflandırmak istiyorum. Siz değerli ustaların bilgisine ihtiyacım var.
def mail_gonder(gonderilenler, konu, body_mail):
sender = 'deneme@gmail.com'
receivers = gonderilenler
html_body_of_email = body_mail
msg = MIMEText(html_body_of_email, 'html')
msg['Subject'] = konu
msg['From'] = sender
msg['To'] = ','.join(receivers)
s = smtplib.SMTP_SSL(host = 'smtp.gmail.com', port = 465)
s.login(user = 'deneme@gmail.com', password = 'asdasdadasda')
s.sendmail(sender, receivers, msg.as_string())
s.quit()
def durus_mail_gonder(gonderilenler, tarih, baslangic):
body_mail = """\
<html>
<head>
<style>
table th {
font-size: 24px;
font-weigth: bold;
}
</style>
</head>
<body>
<table border="1" style="color: white; background: red;">
<tr><th colspan="2">TEST MAİLİ</th></tr>
<tr><th colspan="2">MAKİNE 1 ARIZADAN DOLAYI DURUŞ OLMAKTADIR.</th></tr>
<tr><th>DURUŞ BAŞLAMA SAATİ</th><th>""" + str(baslangic) + """</th></tr>
<tr><th colspan="2">ACİL MÜDAHALE GEREKMEKTEDİR.</th></tr>
</table>
</body>
</html>"""
mail_gonder(gonderilenler, "Problem Bildirimi %s" % tarih, body_mail)