[Skip To Content]


# Siggy Stardust

If you’ve ever been frustrated by the lack of control that most mail clients give you over your signatures, then Siggy Stardust is for you. It’s basically an SMTP proxy, which simply adds signatures to the end of any mails you send according to rules that you set up. The rules are written in pure Ruby, and so you can do pretty much anything you want within them.

For example, here is my current rules file at Teh Office. If all the recipients of a mail are within 29degrees, then a personal signature is appended. If any of the recipients are external to the company, then the business signature gets added. My personal signature tries to include the song I’m listening to at the moment, either on my own computer, or on the company jukebox. It does this by querying either iTunes or last.fm.

  1. require 'rubygems'
  2. require 'rbosa'
  3. require 'scrobbler'
  4. rules do
  5. smtp_server( "localhost" )
  6. smtp_port( 10025 )
  7. track = nil
  8. track_string = nil
  9. begin
  10. # Try and get currently playing information from either iTunes or last.fm.
  11. itunes = OSA.app( "iTunes" )
  12. if itunes.player_state == OSA::ITunes::EPLS::PLAYING
  13. track = itunes.current_track
  14. else
  15. user = Scrobbler::User.new( "29degrees" )
  16. track = user.recent_tracks.first
  17. end
  18. rescue
  19. puts [ $!.class, $!.to_s, $!.backtrace ]
  20. end
  21. if track
  22. track_string = "\"%s\" by %s off \"%s\"" % [ track.name, track.artist, track.album ]
  23. personal_sig = <<-EOT
  24. --
  25. Now listening to : #{track_string}
  26. Siggy Stardust r78
  27. EOT
  28. else
  29. personal_sig = <<-EOT
  30. --
  31. ASCII a silly question, get a silly ANSI.
  32. Siggy Stardust r78
  33. EOT
  34. end
  35. business_sig = <<-EOT
  36. --
  37. Regards,
  38. Carl Drinkwater,
  39. Director.
  40. http://29degrees.co.uk - Bespoke Web Application Development
  41. +44 (0) 161 953 6669 - +44 (0) 776 043 1463
  42. 29degrees Ltd is registered in England and Wales under company
  43. number 05952987. VAT Reg Number GB897293655. Registered office
  44. St. George's House, 215/219 Chester Road, Manchester, M15 4JE.
  45. EOT
  46. if recipients.all_in_domain?( "29degrees.co.uk" )
  47. append_sig( personal_sig )
  48. else
  49. append_sig( business_sig )
  50. end
  51. end

(Does anyone else think heredocs are ugly?)

Siggy tries to be intelligent when adding signatures to multipart emails. For me, the best results have come by adding the signature to the end of the last text/plain part of the email, and so that’s what Siggy does. It doesn’t attempt to do anything with text/html emails, because it shouldn’t need to.

If you want to play, download Siggy Stardust here. Run it by doing something like :

  1. ruby ./server.rb rules.rb

You’ll need to re-configure your mail client’s SMTP setting to use localhost and port 1234. By default, Siggy will proxy through to port 25 on the local machine, but you can change that by using the smtp_server and smtp_port methods as in my rules file.

The only other real helper functions are demonstrated in the final lines of my rules file :

  1. if recipients.all_in_domain?( "29degrees.co.uk" )
  2. append_sig( personal_sig )
  3. else
  4. append_sig( business_sig )
  5. end

You will probably need to write more to do the things you want, you’ll need to do that in server.rb.

To use the ‘now playing’ functionality, you’ll need the appropriate Rubygems installed. The iTunes lookup uses RubyOSA, and is only available on OS X.

Lastly, the rules file is reloaded each time you send an email through Siggy, so you don’t need to restart the server if you edit your rules.

The two files comprising Siggy Stardust, rules.rb and server.rb, are placed in the public domain. However, note that the gzipped-tar archive you can download above comes packaged with TMail, and is licensed under the LGPL.

More about this site...

Last Week’s Top 5 Albums (More »)

  1. The SinglesThe Bluetones
  2. Night on My SideGemma Hayes
  3. PlansDeath Cab for Cutie
  4. Slipway FiresRazorlight
  5. Brain Thrust MasteryWe Are Scientists