Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#!/bin/sh # ~/bin/intermail - intercepts mail sent with sendmail (kind of) # By Edrx, 2004dec23 # The problem: my main e-mail address is <[email protected]>, but my # account at mat.puc-rio.br only allows me shell access through ssh -- # no pop3, so smtp, no imap, no anything... how can I read the mail # that falls there, and how can I send mails that seem to originate # from there? # # I know that most of you will have several answers ready: "use # another e-mail account and set the `reply-to' field"; "use procmail, # .forward and reply-to", etc etc -- # # but: # # I DON'T BLOODY FSCKING UNDERSTAND HOW E-MAIL WORKS!!! I've tried to # experiment with sendmail, exim4, postfix, and even a bit of qmail, # I've read tons of docs and RFCs and tried to assimilate what was # there, but these programs are still surprising me all the time; a # few days ago I tried to fetchmail mails from another ssh-able # account that I've had for years, one in which running "mail" showed # just five messages, and fetchmail reported 1117 messages, then # started to download them, and when I noticed I wasn't receiving them # and aborted it I found that the 20-something messages it fetched # (certainly all spam, but whatever) were either lost or in some # mysterious limbo directory, because I didn't have an MTA # installed... yeah, really, no MTA, because due to a disk crash I # recently had to reinstall my home machine, and I used debootstrap # for that and for some reason I didn't choose an MTA... # # FSCK! FSCK EVERYTHING! FSCK ME! FSCK THE SYSTEM! FSCK FSCKING ESR! # BASTARD! TRAITOR! FSCK! FSCK! AAAAAAAARGH! AAAAAAA! AAAAAAA! # # E-mails are made to be *deleted*, not to be *lost*. If I have an # e-mail account that is more or less dependable -- the one at puc-rio # -- I shouldn't be risking my precious spammy e-mails because I'm # bloody trying to play the sysadmin and I'm bloody incompetent to do # so. I *will* understand this e-mail shit someday, when I'll have a # virtual second machine to play with, but right now qemu just broke, # I still don't know how to use user-mode-linux, and I'm *not* going # to use that fscking sourceless vmware thing, especially because my # old HD just went "poof" and with it went my shiny new, never # untarred tarball of bloody bloated fscking vmware, and when I did # download it I had broadband and I don't have fscking broadband # anymore, I'm on fscking dial-up now. # # Reading puc-rio's e-mails is fine, I just rsync my mailbox there # from time to time. Sending e-mails is more of a problem: I used to # write each e-mail as an invocation of mail -s SUBJECT TO1 TO2 etc # etc, with the body of the e-mail as a here-document; then I would # upload that to puc as a script and run it there. But the machine at # puc runs that wonderfully crappy RH 6.1, in which "mail" doesn't # even accept an "-a" to set extra headers, so no In-Reply-To's or # such stuff. Yeech. Yeah, I *did* live for years without ever # replying properly, and I just discovered "-a" some weeks ago. But # for mailing lists I do need "In-Reply-To"s, and if I want qemu and # user-mode-linux working then blah-blah-blah blah mailing lists. # # Now I just found out that oldy deary sweety nifty cuddly Emacs has a # very simple mode for composing mail that does the headers thing # right; after we compose the mail it invokes /usr/bin/sendmail, # passes on all the headers and stuff, and all things work. # # (find-efile "mail/") # (find-enode "Mail Headers" "`In-reply-to'") # (require 'sendmail) # (find-efunction 'mail) # (find-efunction 'sendmail-send-it) # (find-efunction 'sendmail-send-it "boundp 'sendmail-program") # # Args are usually "- -oi -oem -odb -t": # (find-node "(exim4)-oi" "a dot on a" "not terminate") # (find-node "(exim4)-oem") # (find-node "(exim4)-oee") # (find-node "(exim4)-odb") # (find-node "(exim4)-t") # # So instead of invoking /usr/lib/sendmail we make it invoke this # script; this script writes the sendmail arguments and input into # files in ~/INTERMAIL/, and then we can do funny things with that, # like uploading those files to puc and running a real sendmail there, # and/or storing the files forever. # (setq sendmail-program "~/bin/intermail") # (setq sendmail-program "/usr/lib/sendmail") # (makunbound 'sendmail-program) # (find-angg ".emacs" "intermail") # (find-angg ".zshrc" "intermail") mkdir -p ~/INTERMAIL cd ~/INTERMAIL || exit 1 if [ ! -e n ]; then echo 0 > n fi N=$[$(<n)+1] echo "$*" > $N.args cat > $N.input echo $N > n # That's it. # Cheers.