Ejemplo n.º 1
0
 def __call__(self, timestamp, ip, community, pdu):
     tr = traps.TrapRecord(timestamp, ip, community, pdu)
     ezmail.mail(str(tr),
                 To=self._recipients,
                 From=self._from,
                 subject="Trap from %r" % (str(ip), ))
     return False
Ejemplo n.º 2
0
def mailmessage(cp):
	parts = []
	# main message text and subject line
	body = CF.mail.body(line=CF.lines.get(cp._device), caller_id=cp.caller_id, caller_name=cp.caller_name)
	parts.append(body)
	subj = CF.mail.Subject(line=CF.lines.get(cp._device), caller_id=cp.caller_id, caller_name=cp.caller_name)
	# ogg file attachment
	oggfile = tempfile.NamedTemporaryFile(suffix=".ogg", prefix="voicemail", dir="/var/tmp")
	Vgetty.rmd2ogg(cp.inname, oggfile.name)
	oggfile.seek(0)
	ogg = ezmail.MIMEApplication.MIMEApplication(oggfile.read(), "ogg")
	ogg["Content-Disposition"] = "attachment; filename=%s" % (os.path.basename(cp.inname.replace("rmd", "ogg")), )
	oggfile.close()
	parts.append(ogg)
	# mail it!
	ezmail.mail(parts, subject=subj, To=CF.mail.To)
Ejemplo n.º 3
0
	def finalize(self):
		"""finalizing this Report sends off the email."""
		self.write(self._formatter.finalize())
		report = ezmail.MIMEText.MIMEText(self._fo.getvalue(), self._formatter.MIMETYPE.split("/")[1])
		report["Content-Disposition"] = "inline"
		self._message.attach(report)
		if self._logfile:
			try:
				lfd = file(self._logfile).read()
			except:
				pass # non-fatal
				print >>sys.stderr, "could not read or attach log file: %r" % (self._logfile,)
			else:
				logmsg = ezmail.MIMEText.MIMEText(lfd)
				logmsg["Content-Disposition"] = 'attachment; filename=%s' % (os.path.basename(self._logfile), )
				self._message.attach(logmsg)
		ezmail.mail(self._message)
Ejemplo n.º 4
0
 def __call__(self, timestamp, ip, community, pdu):
     tr = traps.TrapRecord(timestamp, ip, community, pdu)
     ezmail.mail(str(tr), To=self._recipients, From=self._from,
                 subject="Trap from %r" % (str(ip),))
     return False