On Wed, Sep 10, 2003 at 11:41:32AM -0500, Ben Bargabus wrote: > Why are we limiting to emails under 1K (or 50K in your follow up > email)? Only a logic decision. We don't want to have to parse 1MB of a message if we only care about the first 10k. Plus, whomever is sending the message should know how big of a message is allowed. Now, on to the rest of your message. Rather than typing "Yep" for things that you got right, I'll only comment on things that need clarification. > > :0 fw > > | formail -r -k -I "From: $FROM" > So we're reformatting the email to remove all headers except for "From" > which we saved earlier using the MATCH variable? Kind of. formail creates a reply message with the '-r' option, keeps the body with the '-k' option, prefixing it with the default '>'. formail generally creates sane "To:", "Subject:", "In-Reply-To:", and "References:" headers. We're overriding anything it might have decided was good for the "From:" header to something small to parse. Sendmail doesn't need much to send email. It could get away with something as simple as: shell$ echo This is a message | sendmail address at host Sendmail will add the missing headers: From, To, Date, Message-Id. From and To are special. For the "From: " field, it'll add something like "From: chewie at skuld.wookimus.net (Chad Walstrom)". The "To:" field will become "To: undisclosed-recipients;". So, that's quite a few extra characters we really don't need. We therefore use formail to give us sane values. We could use "echo" instead, if you like: PADDR=XXXXXXXXXX at smsgateway :0 fhw | ( echo "To: $PADDR" ; \ echo "From: chewie at wookimus.net" ) :0 afbw | head -c 150 | $HOME/bin/sms-bodycrunch :0 a ! $PADDR :0 e pager-fail where sms-bodycrunch is a sed script: #!/bin/sed -f s/[:punct:]//g s/[Tt]he //g s/[Mm]essage/msg/g s/[Ss]erver/svr/g s/[Aa]\( \)?//g s/[Aa]nd/+/g s/[Tt]herefore/thr4/g s/[Cc]haracter/char/g s/[Aa]ttention/ATTN/g s/[Aa]ddress/addr/g s/ing/g/g s/tion/tn/g s/ish/sh/g s/ould/ld/g # crunch space s/[:space:]{2,}/ /g # Email signature text, quit /^--\( \)?$/ q # EOSCRIPT We may not actually need any headers, assuming, of course, that the SMS gateway you're using will accept messages without headers. To test, find the MX record for the SMS gateway and use telnet to debug. *[12:58:25] chewie at skuld (577)$ telnet mailx03.tmomail.net 25 Trying 63.122.5.248... Connected to 63.122.5.248. Escape character is '^]'. 220 mail2.microsoft.com MailShield SMTP (UCE NOT WANTED) EHLO wookimus.net 250-Hello wookimus.net [66.41.19.116], pleased to meet you 250 SIZE 8192000 RCPT TO XXXXXXXXXX at tmomail.net 500 Command unrecognized RCPT TO: XXXXXXXXXX at tmomail.net 250 < XXXXXXXXXX at tmomail.net>... Recipient ok MAIL FROM: chewie at wookimus.net 250 < chewie at wookimus.net>... Sender ok DATA 354 Enter mail, end with "." on a line by itself This is a test message. -- CCW . 250 Message received (relayed by MailShield) QUIT 221 mail2.microsoft.com closing connection Connection closed by foreign host. I haven't received my SMS messages yet, since my office doesn't get very good reception for messages. When I get home, I'll be bombarded with them, though. ;-) Regardless, email messages are currently the easiest email->sms we have. Minimize the character content being sent, and you should be doing just fine. > Are these commented out because the formail line above already removed > all headers but "From"? If I wanted to keep both From and Subject > could I do... No, as I mentioned above, I left them comment out because I wasn't confident that your SMS email-gateway allowed sparse headers. > instead of the formail statement above? Is there an easier/better way > to do that with formail? Maybe. If you build your own headers and then construct a sed script or perl script to handle the stripping of content, you could do without formail. -- Chad Walstrom <chewie at wookimus.net> http://www.wookimus.net/ assert(expired(knowledge)); /* core dump */ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available Url : http://shadowknight.real-time.com/pipermail/tclug-list/attachments/20030910/0536891f/attachment.pgp