AdrianJ217 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a contact form on a website where a user enter's his/her name, email address and comments. Then when they click "send" it will go to a perl cgi script. I know how to save each entry into a variable in the cgi script but the problem is I'm not sure how to get the perl cgi script to send that information directly to my gmail account. Could someone help me? Thank you very much.

Replies are listed 'Best First'.
Re: sending email through cgi
by boftx (Deacon) on May 18, 2014 at 19:44 UTC

    There are many, many modules on CPAN that can do what you want, but I strongly suggest that you read up on the various security problems you can introduce if you are not familiar with web-based email.

    It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

      Hi, yeah I have tried several modules but there was no success. For the Mail::Sendmail module, after I did a test on the contact form and pressed "send" I got this response: Can't locate Mail/Sendmail.pm in @INC (@INC contains: /private/software/lib/perl5/site_perl/5.8.8/ /private/software/lib/perl5/5.8.8/ /private/software/lib64/perl5/5.\8.8/ /private/software/lib/perl5/x86_64-linux-thread-multi /private/software/lib/perl5/5.8.8 /private/software/lib/perl5/x86_64-linux-thread-multi /private/software/lib/perl5 /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /home/ls/adrian/public_html/cgi-bin/contact.cgi line 7. BEGIN failed--compilation aborted at /home/ls/adrian/public_html/cgi-bin/contact.cgi line 7.

        If you happen to be on a Linux box, then you might find it easiest to use the sendmail command (or alternative).

        Perl doesn't have email capabilities built in, so it's recommended to install a module for this if you don't already have one installed. This has become quite easy with cpanminus.

        The obvious response is where is Mail::Sendmail installed? (assuming it is. If not, then you have to get that from CPAN first.)

        It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.