sending email w/perl
I have a script where I am searching ebay
to get results and email these to myself.
The filehandle is FILE but everytime I
try to insert FILE into the $smtp it
prints "FILE" and not the contents of file.
What is the fix for this?
use WWW::Search;
open(FILE,">eltonjohn.txt");
print FILE "Results of a search for Elton John MFSL on ebay\n\n\n\n";
my $oSearch = new WWW::Search('Ebay');
my $sQuery = WWW::Search::escape_query("Elton John MFSL");
$oSearch->native_query($sQuery);
while (my $oResult = $oSearch->next_result())
{ print FILE $oResult->url, "\n"; }
# { print FILE $oResult, "\n"; }
######## SEND EMAIL INFORMING MYSELF OF EBAY RESULTS #################
#e-mail variables
$mailsender = 'lance@augustmail.com';
$mailserver = 'mail.augustmail.com';
# Then you have a subroutine: (You have to have libnet module installed, ask again if you need directions on how to install this module)
#################################################################### #sends an e-mail
#input: subject, mailto, mailbody
#output: e-mail
####################################################################
sub Email{
#passing the parameters
( $subject, $mailto, $mailbody) = @_;
use Net::SMTP;
$smtp = Net::SMTP->new($mailserver);
$smtp->mail($mailsender);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("To: $mailto\n");
$smtp->datasend("From: $mailsender\n\n");
# $smtp->datasend($mailbody);
$smtp->datasend(FILE);
$smtp->datasend();
$smtp->quit;
} #Email
&Email('Elton John Ebay Results','lance@augustmail.com');
close(FILE);
Reply to: