My company is making a small jump from Google Apps Standard this morning to the Premier service, but because we are taking the opportunity to change the domain name, we are forced to do a migration. This is really not a big deal compared to the mail migrations I have done in the past, in fact it’s minor. I have learned however that mail always needs lots of attention or else it will bite you.
I have to add about sixty users to Gmail, so I worked up a CSV file with username, first, last and temporary password fields the latter of which I pasted randomly generated passwords from PerfectPasswords. This list will get uploaded to Google to create all the new account and set the temp passwords, but there is no service to then email the old accounts and provide this info to the user. So I knocked up a little perl script to parse the csv file, which I called ‘output.csv’ (the output from my awk script that I used to create it) and email each person in the list and give them their credentials. here is the script:
use strict;
use Net::SMTP;
read_file();
exit;
sub read_file
{
open(FILE, "output.csv") or die("Unable to open file");
my @data = <FILE>;
for my $lines (@data) {
chomp($lines);
if($lines =~ m/^Username/) {
next
}
my @line = split (',', $lines);
email_report(@line);
}
close(FILE);
}
sub email_report
{
my ($uname,$first,$last,$passwd) = @_;
my $email_address = "$uname\@yourdomain.org";
my $smtp = Net::SMTP->new("mailsrv.yourdomain.org",
Hello => 'sending.serverdomain.org',
Timeout => 60);
$smtp->mail("from_address\@yourdomain.org");
$smtp->recipient("$email_address");
$smtp->to("$email_address");
$smtp->data;
$smtp->datasend("From: from_address\@yourdomain.org\n");
$smtp->datasend("To: $email_address\n");
$smtp->datasend("Subject: !! Important !! New Email Account Information\n");
$smtp->datasend("\n");
$smtp->datasend("New email day is here!\n");
$smtp->datasend("Your email is going to your new account \"\@newdomain.org\".\n");
$smtp->datasend("Below is how you log into your account for the first time. Please take time to do this now. \n");
$smtp->datasend("\n");
$smtp->datasend("Click the link below\n");
$smtp->datasend("http://mail.google.com/a/newdomain.org\n");
$smtp->datasend("Your Username is: $uname\n");
$smtp->datasend("Your Temporarry Password is: $passwd\n");
$smtp->datasend("Your new email address is: $name@newdomain.org\n");
$smtp->datasend("If the information above is incorrect or you have trouble logging in see a Mail Team member.\n");
$smtp->dataend;
$smtp->quit;
}





Recent Comments