Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: mail in script... how to add subject and from:

by kilinrax (Deacon)
on Oct 16, 2000 at 20:34 UTC ( [id://36947]=note: print w/replies, xml ) Need Help??


in reply to mail in script... how to add subject and from:

I'd use Mail::Mailer;
sendmail ('god@heaven.com', 'die.puny@earthling.net','Test', 'This is +a test'); sub sendmail { my ($from, $to, $subject, $body) = @_; my $mailer; eval { $mailer = Mail::Mailer->new('sendmail'); }; if ($@) { warn "Couldn't send mail: $@"; } else { $mailer->open({ From => $from, To => $to, Subject => $subject }); print $mailer $body; unless (close ($mailer)) { warn "Couldn't close mailer: $!"; } } }
Also, check that whichever user is sending the mail is allowed to set the 'From:' field.
For instance, if you're using exim, add them to the 'trusted users' section of /etc/exim.conf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://36947]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found