#!/usr/bin/perl -w use strict; use Email::Send; use Email::Send::Gmail; use Email::Simple::Creator; my $to = $ARGV[0]; my $from = $ARGV[1]; my $pass = $ARGV[2]; my $prog = (split /\//, $0)[-1]; die "\n\tusage: $prog to from pass\n" if(!$to || !$from || !$pass); for(my $i=99; $i>0; $i--){ my $y = $i - 1; my $bottles = 'bottle'; $bottles .= 's' if(!($i == 1)); my $line = "$i $bottles of beer on the wall, " . "$i $bottles of beer, take one down " . "pass it around, $y bottles of beer " . " on the wall.\n"; my $email = Email::Simple->create( header => [ From => $from, To => $to, Subject => '', ], body => $line, ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => $from, password => $pass, ] } ); print $line, "\n"; eval { $sender->send($email) }; die "Error sending email: $@" if $@; }