Link to home
Start Free TrialLog in
Avatar of kurian2z5
kurian2z5Flag for India

asked on

Send Email

how do i send an email using perl. when user submits form to the form.cgi, it verifies that the data is correct. how do i make it send the data by e-mail to any address.
i need full code (newbie) and whatever server settings to be set.
ASKER CERTIFIED SOLUTION
Avatar of rj2
rj2

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
here is example I wrote in my project few weeks ago :

this script scans for files under /dumps and send mail to all the files' owners .

#!/usr/local/bin/perltk -w

$dul_str = "ls -lR /dumps/* | sort -k 5 -nr | grep trn";
@dul = qx ( $dul_str ); # | sort -k 5 -r | grep trn");
$mail_list = "";

foreach $line (@dul) {
    $line =~ /.*\s+(\w+)\s*ftp/;
    if ($mail_list =~ /$1/) {
    } else {
        $mail_list .= $1."\@pop3".",";
    }
}

$mail_str = "ls -lR /dumps/* | mail -s \"clear dumps on $ENV{'HOST'} - by script\" $mail_list";
system ($mail_str);
exit(1);

good luck ,


tal
Avatar of kurian2z5

ASKER

also, how do i add the sender's name ?
normally it's displayed in the from address as
<Senders Name> "Email address" but it doesnt work if i type this in $from
how would i do this in MIME Lite ?
..
$mail_list .= "$ENV{'USER'}";

$mail_str = "ls -lR /dumps/* | mail -s \"clear dumps on $ENV{'HOST'} - by script\" $mail_list";

tal
um... how exactly does that work ?