+ def mail(self, to):
+ sendmail = os.popen("/usr/sbin/sendmail -N never -t -f%s" % self.config.PLC_MAIL_SUPPORT_ADDRESS, "w")
+
+ subject = "[PLCAPI] Maximum allowed number of API calls exceeded"
+
+ header = {'from': "%s Support <%s>" % (self.config.PLC_NAME, self.config.PLC_MAIL_SUPPORT_ADDRESS),
+ 'to': "%s, %s" % (to, self.config.PLC_MAIL_SUPPORT_ADDRESS),
+ 'version': sys.version.split(" ")[0],
+ 'subject': subject}
+
+ body = "Maximum allowed number of API calls exceeded for the user %s within the last %s minutes." % (to, self.minutes)
+
+ # Write headers
+ sendmail.write(
+"""
+Content-type: text/plain
+From: %(from)s
+Reply-To: %(from)s
+To: %(to)s
+X-Mailer: Python/%(version)s
+Subject: %(subject)s
+
+""".lstrip() % header)
+
+ # Write body
+ sendmail.write(body)
+ # Done
+ sendmail.close()
+