Link to home
Start Free TrialLog in
Avatar of fabiogaravelli
fabiogaravelli

asked on

sendmail perl solution

Hi experts,
i have this situation on my server, crontab runs in cron.daily and check the last revision on subversion server,make backup ,gzip the last revision and so on , at the it make rsync on storage server.I need to send mail to some user with the result of the operation.I need that define the user on a file in this way ...user1@serverone.one,user2@servertwo.two and so on. and the subject define on file in the same way on user ...
in this way , i can change the user list when i want , and the subject i populate it with result of crontab operation.
Bye
Avatar of ozo
ozo
Flag of United States of America image

use Mail::Sendmail;

  %mail = ( To      => 'user1@serverone.one,user2@servertwo.two ',
            From    => 'me@here.com',
            Message => "This is a very short message"
           );

  sendmail(%mail) or die $Mail::Sendmail::error;

  print "OK. Log says:\n", $Mail::Sendmail::log;
Avatar of fabiogaravelli
fabiogaravelli

ASKER

ok ,but i need to pass as argument the value of To ,From , Message because they come from external configuration file.
file1..it contains the To parameters
file2 it contains the message
%mail = ( To      => $to,
            From    => $from,
            Message => $message,
           );
ok ozo.... but in which way i can create the $to... better how i can but in $to the content of the file ?
open T,"<file1" or die "file1 $!";
$to = <T>;  #assuming it is on the first line of the file
close T;
open M,"<file2" or die "file2 $!";
$message = join'',<M>;
close M;

can u explain me better i'm just little bit newbie on perl :-)
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
som eprob with sendmail.pm installation ... make,make test make install everything is ok when i run perl myperl.pl i receive this...
Can't locate Mail/Sendmail.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.7 /usr/local/share/perl/5.8.7 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at myperl.pl line 3.
what it mean?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial