#!/usr/bin/perl require "send_mail.pm"; $title = "my title"; $desc = 'my desc'; $link = 'http://www.google.com'; $epoch = 1287629117; $file_name = 'file.txt'; $input[2] = 'kevin@mydomain.net'; &send_mail::send_email ($title, $desc, $link, $epoch, $file_name, \$$input[2]); #### package send_mail; sub send_email (){ my ($title, $desc, $link, $epoch, $name, $emails) = @_; use POSIX qw(strftime); my $est = strftime "%a, %B %d, %Y, %X %z", localtime($epoch); my $smtp = Net::SMTP->new('mail.mydomain.net', LocalAddr => 2626, Timeout => 10, Debug => 1 ); $smtp->auth( 'kevin@mydomain.net', 'password'); $smtp->mail('kevin@mydomain.net'); # use the sender's adress here my @em = split (',',$$emails); foreach (@em){ $smtp->to($_); # recipient's address } $smtp->data(); # Start the mail $smtp->datasend("Subject: " . $title); $smtp->datasend("\n" . $desc . "\n" . $link . "\nListing time: " . $est ); $smtp->datasend("\n\n bunch of text here " . $name); $smtp->dataend(); # Finish sending the mail $smtp->quit; # Close the SMTP connection }