Filtered response in gmail

I use my gmail account to manage multiple email accounts/addresses. I recently wanted to set up a vacation responder for one of my email address. However, the default vacation responder in gmail uses the default email account to send and there is no option to activate vacation responder for a single email address. I found this post on lifehacker that shows how one could set up a flexible auto response system with the use of a gmail account dedicated to auto response. Let gmail 1 be my primary account, and gmail 2 be my dedicated account. Basically,

  1. Add gmail 2 as a forwarding account in gmail 1.
  2. Set up a filter in gmail 1 that forwards to gmail 2.
  3. Add gmail 1 as an account in gmail 2 so that gmail 2 can send as gmail 1.
  4. Set up vacation responder in gmail 2.

Now, emails sent to gmail 1 that fits the condition of the forwarding filter (e.g., “”). Remember to turn off the filter in gmail 1 and vacation responder in gmail 2 when the auto-response is no longer needed.

RSS to twitter and mailing list (email)

In one of my group’s website (operated using Google Sites), I post news and announcements to a page that has an RSS feed. I don’t expect people to visit the website on a daily basis to find updates. With the RSS feed, updates can come to them using their RSS aggregator or reader of choice, such as Google Reader. However, it seems that in the internet-user population, only a subset uses RSS to get their information aggregated. Some uses twitter, and many uses email. I’d like to get the updates out to as many people as possible. However, I don’t like to update each service by itself. My ideal workflow would be to send an email out with the news and the website, RSS feed, twitter, mailing list would be updated. Sending an email out that updates twitter and a mailing list would be easy. However, updating the website and RSS feed would be a lot more complicated, especially where you don’t have access to the site’s files via ftp or ssh (Google Sites is web-based).

The next best thing would be to update the website via the web interface. The RSS feed would get updated automatically. To get the news to Twitter, there is a free service called twitterfeed. To get the news to a mailing list, I relied on a cron job based on rss2email. Should I have it post to the organization’s fan page on facebook as well? I haven’t decided yet. What the heck, I’m updating a facebook Group’s page using RSS Graffiti.

Monitor disk usage and send email when disk is nearly full

This site and this site describe some scripts to monitor disk usage of a computer based on the df command and email the ADMIN when disk usage reaches a certain percentage. The scripts can be ran periodically based on cron.

These scripts did not work on my local NAS because I have one filesystem called /dev/mapper/acer-root that takes up two lines in the output of df; hence, the scripts run into an error when trying to grab the 5th column of the output. Also, in recent versions of Ubuntu, /bin/sh is symbolically linked to dash; to get the scripts to work, remove the function keyword or change to /bin/bash on the shebang (#!) line in order for the scripts to run.

I adapted a script found on this site for my own use:

 <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">!/bin/</span><span style="color: #00ffff;">bash</span>

## adapted from ## #### check disk space on filesystems listed filesystems=(/ /boot /h2tb) for fs in ${filesystems[@]}; do disk_space=df -h | grep -E $fs$ | awk '{print $(NF-1)}' max_space=“80” disk_space=${disk_space:-$((max_space-1))} ##[[ “${disk_space%’%’}” -ge “$max_space” ]] && { clear ; echo -e “nWARNING…DISK SPACE ON “$fs” IS AT $disk_spacen”; } [[ “${disk_space%’%’}” -ge “$max_space” ]] && { echo “” | mutt -s “WARNING…DISK SPACE ON “$fs” IS AT $disk_space” MY.EMAIL.ADDRESS ; } done unset filesystems fs disk_space max_space ####

Note that I use mutt to send emails; mail would be simpler and more portable, but it isn’t set up on my server.

I added the following to cron via crontab -e to get the script to run hourly:

 <pre class="src src-sh">0 * * * * /path/to/

GPG/PGP: sign or encrypt emails or files

I always wanted to set this up, but never got around to it because I a particular need never arised. I finally had some time to set up my GPG key so others can send me encrypted files and emails. Google “gpg” or “pgp” for more information about it.


I followed these instructions to set up GPG on my laptop; setup is pretty straightforward. Be sure to back up your public key, private key, and revocation key somewhere safe, like a CD locked up in a fireproof safe:

gpg --list-secret-keys ## Look for the line that starts something like "sec 1024D/". The part after the 1024D is the key_id.
gpg -ao _something_-private.key --export-secret-keys key_id
gpg -ao _something_-public.key --export key_id
gpg --gen-revoke

Remember to import the key if you use multiple computers or got a new computer:

gpg --import _something_-public.key
gpg --import _something_-private.key


This is a good beginner’s reference for GPG. Some parts are also based on this page, although it is for the pgp command as opposed to the gpg command.

Remember to place the following in ~/.bashrc so that GPG uses your key id as the default:

export GPGKEY=key id

Import trusted people’s public keys:

gpg --import public.key.file
gpg --list-keys ## list to see who we have

Encrypt file:

gpg --encrypt MyFile ## optional (prior to --encrypt): --out OutFile
## select person from your public keys ring via key id or email address

Now send the encrypted file to the person. Only he/she can open it using his/her private key.

Decrypt file:

gpg --decrypt MyFile ## optional (prior to --decrypt): --output OutFile
## enter passphrase

Signing is used to let others (with your public key) know that the message/file was indeed from you and has not been tampered with while being transported to you. The content is not private but the origin is of concern.

Signing a file:

gpg -sat textfile ## clear sign a file (--sign --armored --text) so that the original text and content are in the same file
## enter passphrase

gpg -sb binaryfile ## (--sign --detach-sign): a separate binary .sig file is generated to be delivered with the binary file
## enter passphrase

gpg -sab binaryfile ## (--sign --armored --detach-sign): a separate armored text signature .asc file is generated to be delivered with the binary file
## enter passphrase

## sign and encrypt
pgp -seat textfile "To User ID"
pgp -se binaryfile "to recipient ID"
pgp -sea binaryfile "to recipient ID"

Reading a file:

gpg gpgfile ## "This is used for all PGP files, be they encrypted, signed or a key file. PGP will handle it all automatically."
gpg signaturefile signedfile ## detached signature file

Use with Email

Since I use gmail in the web browser primarily, I’m unable to integrate GPG with gmail since FireGPG is now discontinued. I have a feeling a chrome extension will come to fruition soon.

Currently, if I want to send signed emails, I do so in Evolution Mail per the setup instructions. I will update this post on how to do it using mutt or emacs soon.

To check on signatures sent to my email, what I do is open using “Show original” and pasting the content into a text file on my computer. I use the clearmime script as follow:

$ clearmime | gpg --verify # expects you to paste a raw email message
$ clearmime < myemail.txt | gpg --verify # reads the raw email from a file

UPDATE 9/29/2010: Using GPG with mutt is actually quite easy. I followed these instructions. Basically, after mutt is set up to be able to send mail, I added the following to my ~/.muttrc file:

## gpg with mutt
## following for debian only (location)
source /usr/share/doc/mutt/examples/gpg.rc
## or paste content into .muttrc file

Now, type mutt in the command line, select mail, and compose. After composing the mail, type p to select whether you want to sign, encrypt, etc. Note that I believe you have to be in the mutt program to access GPG options. I don’t think sending signed/encrypted email from the command line with mutt is an option.

Also, to open encrypted emails from my gmail in the web browser (I already covered how to verify a signature previously), I just download the attached encrypted message by copy and paste and type the following:

gpg EncryptedMail.asc
## enter passphrase


My public key is available on my personal website for others to use to send me encrypted emails and files. I’ve also uploaded to the keyservers. However, I have not had anyone verify me in the physical world, so you might get a WARNING message.

UPDATE 9/8/2011 Revoke Keys

I recently decided to revoke the keys I set up last year. Why? The passphrase was too short. The passphrase should be long in order to protect myself from a brute-force attack. According to this, the passphrase should be 22+ characters in length to be equivalent to a 128 bit key, and 42+ characters long to be equivalent to a 256 bit key. Thus I revoked my current key and will create a new one.

To revoke, I followed these instructions:

gpg --import revoke.asc ## I saved this file in a very secure place
gpg --keyserver --send-keys key_num

To delete the key from my computer, I followed these instructions:

gpg --delete-secret-keys key_num
gpg --delete-keys key_num
gpg --list-key

email yourself when a script or a job is done

i usually run long simulations in R on a remote server. i’ve read an article on linux journal about emailing yourself after something happens…i forgot. since my jobs are long, and i usually have to run multiple jobs sequentially, it’d be nice to look at my results immediately when they’re gone. good thing *nix based systems have the mail (or mailx) command:

<pre class="src src-sh"><span style="color: #b0c4de;">echo</span> <span style="color: #ffa07a;">""</span> | mail -s <span style="color: #ffa07a;">"Job Done"</span>

found the stuff here.

in R, i execute:

<pre class="src src-sh"><span style="color: #87cefa;">system</span>(<span style="color: #ffa07a;">'echo "" | mail -s "Job Done"'</span>)

of course, these are empty emails. u can use “<” or cat with pipe to get results emailed to you. cool!

an innovative idea? blogging by email: posterous

so i recently discovered (through michael zeller again) a new blogging service called posterous. it’s pretty innovative in that u can post by email. really? blogger let’s me do that too, and so does wordpress and most blogging services. however, posterous stands out because it’ll do all the work for u. put in a link to a video and it’ll embed it on your blog. attach and song, same thing. attach multiple pictures and it’ll embed a gallery. want to format ur blog? write the html and posterous will take care of everything. cool huh? look at the list of features yourself. i’m still debating on whether to switch over or keep using blogger. i mean i guess i can start another blog on there for a different topic, but face it, i only have time for one active blog right now, and that i don’t have another interest that i could blog about. to switch or not to switch? some drawbacks i see with posterous:

  1. attaching too many files my gmail will get huge.
  2. security issues with emails…what if someone spoofs my email and posts?

michael zeller points out that he likes the email idea because he could write everything in emacs using org-mode, save them for version control, and email them in emacs. i guess thats a good idea. however, right now my current blog is like a repository for my brain….it’s very random and scattered. i don’t organize (i let google do the organizing). to switch or not? i want to try to switch, but i’m having issues importing. also, i would have to change some links in my blog that refers to the older posts. i chose blogger in the first place because it is simple, integrates well with google, and has a wide support online. hmmm…decisions decisions