Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

emailing form results to a user

by Becky (Beadle)
on Aug 09, 2002 at 15:11 UTC ( #188931=perlquestion: print w/ replies, xml ) Need Help??
Becky has asked for the wisdom of the Perl Monks concerning the following question:

I have a web form set up where users can enter data, which then gets processed by a perl script. At the moment, the results are printed to screen (a new web page) when the user clicks the 'submit' button. I would like to be able to email the results to the user instead by asking for their email address on the form.

I had a look on a few tutorials which told me that I needed to find the 'sendmail' program, which may be found here: /usr/sbin/sendmail. Mine isn't, but I did find a 'sendmail' directory in usr/share/webmin/sendmail. The problem is that I don't know which file within this sendmail directory to refer my program to. Any ideas? Or is there a better way to do it altogether? If it helps, I work in Mandrake Linux.

Comment on emailing form results to a user
Re: emailing form results to a user
by DamnDirtyApe (Curate) on Aug 09, 2002 at 15:15 UTC

    You may be happier using Mail::Mailer, MIME::Lite, or one of the other mail modules on CPAN.


    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche
Re: emailing form results to a user
by neilwatson (Curate) on Aug 09, 2002 at 15:19 UTC
    There is an RPM with mandrake that will install the sendmail binary. You can also use the smtp server that delivers your email. Try using the module mail::sender

    Update: To get you started here is an example of a mail::sender subroutine:

    sub mailout{ $sender = new Mail::Sender; $sender->Open({ smtp => 'mail', #insert your smtp server here from => "$from", fake_from => "$ffrom", to => "$to", encoding => "quoted-printable", subject => "$subject", ctype => "$htype", # could be plain or html }) || die "Sender error: $sender, $Mail::Sender::Error!\n"; # body of email $sender->SendEnc(@body) || die "Sender error: $sender, $Mail::Send +er::Error!\n"; # send email $sender->Close || die "Sender error: $sender, $Mail::Sender::Error +!\n"; }

    Neil Watson
    watson-wilson.ca

Re: emailing form results to a user
by frankus (Priest) on Aug 09, 2002 at 15:19 UTC
    Your on the right track IMO.

    Many OS keep there sendmail program in different places,
    in these situations it is common to find that the OS provide their own packages for the Perl Modules:
    like here for Mandrake (as one for instance).
    In these situations it is better to forsake perl -MCPAN -e 'shell' for RPMs in your case.

    Alternatively you could use symlinks to cobble a solution.

    --

    Brother Frankus.

    ¤

Re: emailing form results to a user
by LTjake (Prior) on Aug 09, 2002 at 15:22 UTC
    This isn't really a solution, but rather an alternative. Instead of using linux's sendmail, try the Mail::Sendmail module. It's a "simple platform independent mailer." Thus, it makes your program more portable should you wish to change your current OS. I've used it on both Windows and Linux with great success. Here's a code sample:
    use Mail::Sendmail; # Create the message hash my %mail = ( To => 'You <your@address.com>', # To address.. From => 'Me <my@address.com>', # From address.. Message => 'Hello, world!', # The message body.. Smtp => 'your.mail.server' # erase this if you want to use "loc +alhost" (default) ); # Send the message unless (sendmail(%mail)) { # Error! } # All is well.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://188931]
Approved by TStanley
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-10-02 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (66 votes), past polls