Browse Source

Ajout de la fonction "Catch first call": on choppe tout le monde, les appels justifiés essayeront à nouveau.

Jean-Francois Burdet 7 years ago
parent
commit
8f1a69770c
1 changed files with 9 additions and 2 deletions
  1. 9 2
      lenny.py

+ 9 - 2
lenny.py

@@ -19,6 +19,7 @@ import threading
 import urllib2
 import wave
 from datetime import datetime
+from email.mime.text import MIMEText
 
 import linphone
 import yaml
@@ -103,7 +104,13 @@ class SipConnection(object):
     def mail(self, mail_cfg, text):
         try:
             server = smtplib.SMTP(mail_cfg["smtp_host"])
-            server.sendmail(mail_cfg["from"], mail_cfg["to"], text)
+
+            msg = MIMEText(text)
+            msg['Subject'] = text
+            msg['From'] = mail_cfg["from"]
+            msg['To'] = mail_cfg["to"]
+
+            server.sendmail(mail_cfg["from"], [mail_cfg["to"]], msg.as_string())
             server.quit()
         except smtplib.SMTPException as e:
             self.log("Error sending email " + e.message)
@@ -318,7 +325,7 @@ class SipConnection(object):
                     self.mail(mail_cfg, "Appel entrant : " + number)
 
             if type == self.MailType.Notify_Incoming_Telemarketer_Call:
-                self.mail(mail_cfg, "Appel télémarketeur entrant : " + number)
+                self.mail(mail_cfg, "Appel telemarketeur entrant : " + number)
 
     def is_in_blacklists(self, a_number):
         return self.is_in_local_blacklist(a_number) or self.is_in_directory_ch_blacklist(