poolnoodle: the default email2sms script doesn't work for me.
so i tried my hand on a python script.
u may try out my script.
1. replace your email2sms with script below and save as email2sms.py
2. change your postfix master.cf to point to email2sms.py instead.
===================================
#!/usr/bin/env python
import email.parser
import sys
import string
import random
import os
import pwd
import grp
full_msg = sys.stdin.readlines()
msg = email.message_from_string(''.join(full_msg));
ranext = (''.join(random.choice(string.ascii_lowercase) for i in range(9)))
sms_file = open("/var/spool/sms/outgoing/sms."+ranext, 'w')
print >> sms_file, "To:",msg['to'].split('@')[0][1:]
print >> sms_file, "\nSubject:",msg['subject']
print >> sms_file, "Date:",msg['date']
""" Do not include msg.get_pyload for Zabbix """
print >> sms_file, "\n",msg.get_payload()
sms_file.close()
path = "/var/spool/sms/outgoing"
for root, dirs, files in os.walk(path):
for file in files:
fname = os.path.join(root, file)
os.chown(fname, pwd.getpwnam("smsd").pw_uid, grp.getgrnam("smsd").gr_gid)
========================
cheers!
|