From owner-freebsd-isp@FreeBSD.ORG Thu Jun 1 19:21:20 2006 Return-Path: X-Original-To: freebsd-isp@freebsd.org Delivered-To: freebsd-isp@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DB07A16B09B for ; Thu, 1 Jun 2006 19:21:20 +0000 (UTC) (envelope-from bsam@bsam.ru) Received: from mail.kuban.ru (mail.kuban.ru [62.183.66.246]) by mx1.FreeBSD.org (Postfix) with ESMTP id 31F1A43D58 for ; Thu, 1 Jun 2006 19:21:19 +0000 (GMT) (envelope-from bsam@bsam.ru) Received: from bsam.ru ([83.239.48.177]) by mail.kuban.ru (8.9.1/8.9.1) with ESMTP id k51JL1Y2027811; Thu, 1 Jun 2006 23:21:11 +0400 (MSD) Received: from bsam by bsam.ru with local (Exim 4.60 (FreeBSD)) (envelope-from ) id 1FlsiO-0000DN-W1; Thu, 01 Jun 2006 23:20:16 +0400 To: Odhiambo Washington References: <20060601152435.GC51255@ns2.wananchi.com> <03202731@ho.ipt.ru> From: Boris Samorodov Date: Thu, 01 Jun 2006 23:20:16 +0400 In-Reply-To: <03202731@ho.ipt.ru> (Boris Samorodov's message of "Thu, 01 Jun 2006 23:13:56 +0400") Message-ID: <37122351@ho.ipt.ru> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: "Boris B. Samorodov" Cc: freebsd-isp@freebsd.org Subject: Re: Mass SMS X-BeenThere: freebsd-isp@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Internet Services Providers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jun 2006 19:21:27 -0000 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