all repos — mail2mms @ 4e92ed396de1f2d08fc0c3a3af852e3fd38ee4c0

YOU'VE GOT MAIL! notify via MMS of new mail in your inbox

first commit
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iQJDBAABCAAtFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmEjxgQPHG5pbGl4QG5p
bGZtLmNjAAoJEDt/vCIUTmOYlQwP/ijV0Rht6Pe5czqIBedq76I5MdXynsJWmX/0
lu3wL5hHAeOIJ/oB+CFUOle2GPAiwnP6/VojxRlN5Gmr3FfpegybQojgFUpnlNsd
1TSXWaMa1w9Mvh/AogpozEqx/mttsD/xvOvmBEe28s7pSXhZC4Vub7Y6c6n29ef1
tyPB5e26BSlCjUcsTj8E/5qnuXLU8nOCCuXFrhmpO20UzGX1M7mz8H2jmrZNzHWx
hPMAXUct21s0WPuQM77AUd6bHgDaeMXMv78uu7T4LPrRA7uWgjB29+R52Iueu+AA
ij82f7Dp9v4OrO8vaAU77PdkD62yTscLtmX2sVYtCGPmPsUXHUWmjboJL3f9xEp7
JEfvR0Jn87KvqWmeV5OuZNPGucAHy7gWxxNSPWRRPxUY+xu/6xGsPkE1ON462GFm
L9nStTxy/o2D/Vwa/enxZXg0MAguWbm+GimuTLX3/Pt+6FOPwULBgNIZEA0dKr+n
eEq16nZ2iWuOMABatRGVTPO6bbW0hkKIaF+Yk3knNwDp0T18oNJASV2mDO+4b/BQ
00ptBx+NU0rCjzmnijyTeuqdPl8m5Um5V6ZbIGH2CAfd+QHIGJrMyllPWrL+dU8R
m0UwSTKwVtV5mSJ4gts3lPnx9lkKJMB2rMSM9V4GVYaVEVHcSsuYgGs360IImkw2
kuWhyTXV
=UfiP
-----END PGP SIGNATURE-----
commit

4e92ed396de1f2d08fc0c3a3af852e3fd38ee4c0

2 files changed, 58 insertions(+), 0 deletions(-)

jump to
A .gitignore

@@ -0,0 +1,1 @@

+.config
A mail2mms.sh

@@ -0,0 +1,57 @@

+#!/bin/sh + +# Send an MMS message to your phone when new emails come in. +# The message header will have the number of new mails in the subject, +# the From and Subject fields of up to the most recent 3 new mails, +# and 'and more...' if there are more than three new mails +# Assumes you have a maildir inbox on this machine; +# you can use offlineimap or similar to sync recent mail to a maildir + +# import the config file ./.config +# addr=<the address the notification will appear to be sent from> +# phone=<your phone number in email address form (eg, 9876543210@mms.att.net)> +# inbox=<the location of the maildir folder corresponding to the inbox> +# smtp_server=<the address and port (address:port) of your smtp server> +# smtp_user=<the username you use on your smtp server> +# smtp_password<the password to login to the smtp server> + +. ./.config + +if ! pgrep offlineimap; then + offlineimap & +fi + +oldnew=0 + +summary() { + i=0 + for m in $(ls -1r ${inbox}/new/*); do + i=$((i + 1)) + if [ ${i} -gt 3 ]; then + echo "and more..." + break + fi + subject=$(grep ^Subject: ${m} | head -n 1) + from=$(grep ^From: ${m} | head -n 1) + echo ${from} + echo ${subject} + echo + done +} + +while true; do + newnew=$(ls -1 ${inbox}/new | wc -l) + if [ ${newnew} -gt ${oldnew} ]; then + echo "$(summary)" \ + | mail -r nilix@nilfm.cc \ + -s "new mail [${newnew}]" \ + -S smtp=${smtp_server} \ + -S smtp-use-starttls \ + -S smtp-auth=login \ + -S smtp-auth-user=${smtp_user} \ + -S smtp-auth-password=${smtp_password} \ + ${phone} + fi + oldnew=${newnew} + sleep 2m +done