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)
def main(argv): cf = ConfigHolder() cf.VOICEDIR = "/var/spool/voice" cf.MESSAGEDIR = "messages" cf.SPOOLDIR = "incoming" cf.GREETING = "greeting.rmd" cf.LOGFILE = "/var/log/voicemail/voicemail.log" lf = logfile.open(cf.LOGFILE) try: rv = Vgetty.answering_machine(cf, lf) finally: lf.close() return rv