Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Replies are listed 'Best First'.
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 <>', # To address.. From => 'Me <>', # 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.
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.

    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 (Priest) 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

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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://188931]
Approved by TStanley
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2018-02-20 16:16 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (272 votes). Check out past polls.