Howto: Random E-mail Signature in Evolution
Thursday, October 18th, 2007I include Latin phrases in my e-mail signature at work. It’s a fun little thing I do just to make people interested.
So I decided to make a signature that would include a random Latin phrase in every e-mail I send. Thankfully, Evolution makes this easy.
First, I make a text file which I call sigquotes.txt , and stash it in my home directory, under a folder for personal items. I put one quote per line.
Next, I have to write a little ditty to grab a random line from that file and output the results. I used PHP for this, but almost anything could have worked. I dump the following into sigrand.php :
<?
$quoteFile = "/home/icanhaslinux/personal/sigquotes.txt";
$fp = fopen($quoteFile, "r");
$content = fread($fp, filesize($quoteFile));
$quotes = explode("\n",$content);
fclose($fp);
srand((double)microtime()*1000000);
$index = (rand(1, sizeof($quotes)) - 1);
echo "________<br>LightningCrash<br>Resident Unix Witchdoctor<br><br>";
echo $quotes[$index] . "<br>";
?>
Easy enough. I had problems getting the php itself to run as a script, so I had to make another short script to launch the PHP file. I put the following into sigrand.sh :
/usr/bin/php5-cgi -q /home/icanhaslinux/personal/sigrand.php
I chmod +x sigrand.sh and go on my way to the next step.
I fire up Evolution, go to Edit->Preferences. I go to Composer Preferences and click on Signatures. Then I click on the “Add Script” button, name it Random Latin, navigate to /home/icanhaslinux/personal, and select sigrand.sh as my signature script.
That part is done. Now to make it default for my outgoing e-mail. From the Preferences page, I click edit on my e-mail account. On this page, I have a drop-down box where I can select my signature for this account. I select Random Latin, of course. I then click OK and Close.
Now, to test it out, just fire up a new e-mail.
Until next time!
-LightningCrash
EDIT: It’s been requested that I make clear what license this code is issued under. I consider the code snippets on this article to be public domain and not subject to licensing. Use the code in this article as you see fit.
