Date: Thu, 01 Jun 2006 23:20:16 +0400 From: Boris Samorodov <bsam@ipt.ru> To: Odhiambo Washington <wash@wananchi.com> Cc: freebsd-isp@freebsd.org Subject: Re: Mass SMS Message-ID: <37122351@ho.ipt.ru> In-Reply-To: <03202731@ho.ipt.ru> (Boris Samorodov's message of "Thu, 01 Jun 2006 23:13:56 %2B0400") References: <20060601152435.GC51255@ns2.wananchi.com> <03202731@ho.ipt.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 01 Jun 2006 23:13:56 +0400 Boris Samorodov wrote: > command = /usr/local/bin/mail2sms.py > The last script is at the attachement. It uses a Subject field as a Hm, here it is: #!/usr/local/bin/python # $Id: mail2sms.py 6 2005-06-17 19:30:56Z bsam $ from email.Header import decode_header import codecs import email import time import sys dir = '/var/spool/sms' lines = '' while 1: try: line = raw_input() except EOFError: break lines += line.rstrip() + '\n' msg = email.message_from_string(lines) to = email.Utils.parseaddr(msg['To'])[1] f = open(dir + '/db/' + 'phones', 'rb') while 1: try: line = f.readline() except EOFError: print 'Matching not found, exiting!' sys.exit() if not line: print 'Matching not found, exiting!' sys.exit() if line[0] in ('#'): continue line = line.strip() if line in (''): continue phone, who = line.split('\t') if who == to: break subj_full = decode_header(msg['Subject']) enc = subj_full[0][1] if not enc: enc = 'koi8-r' subj = unicode(subj_full[0][0], enc).encode('utf-16') priority = 'Z' smsnum = str(time.time()) fname = 'OUT' + priority + '_' + phone + '_' + smsnum + '.txt' fname = dir + '/outbox/' + fname file = open(fname, 'wb') file.write(subj) file.close() file = open(dir + '/source/' + smsnum, 'wb') file.write(lines) file.close() WBR -- Boris B. Samorodov, Research Engineer InPharmTech Co, http://www.ipt.ru Telephone & Internet Service Provider
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37122351>