| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
"""Email proxy for Avaya's Voicemail Pro (which embeds G-Lock's EasyMail Pro). |
|---|
| 4 |
|
|---|
| 5 |
Voicemail Pro has the capability to send email alerts when a voicemail |
|---|
| 6 |
message is left in a given voicemail box. We use this capability at Amor |
|---|
| 7 |
Ministries, for example, to run an "emergency extension"--if one of our |
|---|
| 8 |
customers has an emergency after hours, they can leave a voicemail message |
|---|
| 9 |
in this box, and various people will be paged to address the issue. |
|---|
| 10 |
|
|---|
| 11 |
Unfortunately, the emails that Voicemail Pro sends out don't follow |
|---|
| 12 |
RFC 821, which requires "MAIL FROM" before "DATA". This causes Exim, |
|---|
| 13 |
which requires spec compliance, to choke. This module runs as an SMTP |
|---|
| 14 |
proxy, fixing up the email from Voicemail Pro and forwarding it on to |
|---|
| 15 |
a designated recipient. It only runs on localhost for security reasons. |
|---|
| 16 |
""" |
|---|
| 17 |
|
|---|
| 18 |
import asyncore |
|---|
| 19 |
import datetime |
|---|
| 20 |
import smtpd |
|---|
| 21 |
|
|---|
| 22 |
def log(msg): |
|---|
| 23 |
msg = "%s %s\n" % (datetime.datetime.now(), msg) |
|---|
| 24 |
open(r"/var/log/vmprofixup.log", "ab").write(msg) |
|---|
| 25 |
|
|---|
| 26 |
class VoicemailProProxy(smtpd.PureProxy): |
|---|
| 27 |
def process_message(self, peer, mailfrom, rcpttos, data): |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
refused = self._deliver("vemergency@amor.org", rcpttos, data) |
|---|
| 31 |
log("Delivery results: %s" % repr(refused)) |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
p = VoicemailProProxy(("192.168.0.6", 2525), ("localhost", 25)) |
|---|
| 35 |
try: |
|---|
| 36 |
log("starting") |
|---|
| 37 |
asyncore.loop() |
|---|
| 38 |
except: |
|---|
| 39 |
p.close() |
|---|
| 40 |
log("stopped") |
|---|
| 41 |
|
|---|