2008-07-31 12-35 Should have used my own script


Okay, this probably won't increase our share price or make us look like these really cool people (that we actually are), but here's a story from the real world. I and Jani were talking about our Summer Campaign and it seemed that Apple's Mail.app didn't send the email to all the intended recipients. So, we decided to complete the mission with a quick script. But which one of us could do it quicker? I started modifying a Python script and Jani decided it would be a better idea to make a simple shell script. Few seconds (oh well okay, it was minutes) later Jani won with this:

myerr() {
 echo $* 1>&2
 exit 1

[ $# -eq 2 ] || myerr  "Usage: $0 <emailaddress-file> <content> "

while read emailaddress
 (echo To: $emailaddress; cat $2) | sendmail $emailaddress
done < $1

I came a good second with this one:

import sys
import time
import smtplib

me = "sales@clarifiednetworks.com"

text = open("test-what").read()
addresses = open("test-who").readlines()

for line in addresses:

    msg = ""
    msg += 'Content-Type: text/plain; charset="iso-8859-1"\n'
    msg += 'MIME-Version: 1.0\n'
    msg += 'Content-Transfer-Encoding: 8bit\n'
    msg += 'Subject: Summer Campaign at Clarified Networks\n'
    msg += 'From: %s\n' % me
    msg += 'To: %s\n' % line
    msg += 'Cc: %s\n' % me
    msg += 'Reply-To: %s\n' % me
    msg += "\n" + text
    print "sending mail to " + line

    s = smtplib.SMTP()
    s.sendmail(me, line, msg)

So, I sent the group email (also known as spam) with Jani's script, but I forgot to edit the default Subject: line which was hardcoded in my own script. So now a good number of people will receive email from Clarified Networks titled "final test". How professional is that! Well, maybe it's the final test before our big release of Clarified Analyzer (artist previously known as Tia) in two months.

Anyway... The campaign is really cool! Please send us email to contact@clarifiednetworks.com if you want to be a part of it. Let's just say that the winner will get utterly cool prizes that will make you look and feel good while analysing your network.

Disclaimer: We are not part of the coder team, they actually know how to do this stuff.

Have fun,

-- jyrki 2008-07-31 12:56:11

No no no, it was actually 'final test' before sending the actual spam. :) We take everything seriously. We even don't send spam before we test it thoroughly. We will soon send the actual mail. We wanted to test our script with as realistic material as possible, so our actual mail will just have different subject.

-- jani 2008-07-31 13:08:51

This is a perfect example what happens when corporation does not concentrate on it's core competence. This service could easily have been outsourced to Russia.

-- jani 2008-07-31 13:20:35

return to the blog ...