CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
sending email through cgi script

 



AdrianJ217
Novice

May 18, 2014, 12:32 PM

Post #1 of 7 (11374 views)
sending email through cgi script Can't Post

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.


FishMonger
Veteran / Moderator

May 18, 2014, 1:31 PM

Post #2 of 7 (11356 views)
Re: [AdrianJ217] sending email through cgi script [In reply to] Can't Post

There are a number of modules available on cpan for sending emails.

Here are several:
Email::Sender - a library for sending email https://metacpan.org/pod/Email::Sender
Email::MIME - easy MIME message handling https://metacpan.org/pod/Email::MIME
Net::SMTP - Simple Mail Transfer Protocol Client https://metacpan.org/pod/Net::SMTP


AdrianJ217
Novice

May 18, 2014, 1:37 PM

Post #3 of 7 (11352 views)
Re: [FishMonger] sending email through cgi script [In reply to] Can't Post

I used Mail::Sendmail but when I went to the contact form on the website and clicked "send" I got this error message:

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.


FishMonger
Veteran / Moderator

May 18, 2014, 1:43 PM

Post #4 of 7 (11346 views)
Re: [AdrianJ217] sending email through cgi script [In reply to] Can't Post

I just saw your cross post on perlmonks.

You need to install the module. Since you posted this question in the Intermediate area, I assume you know how to install modules.

The Net::SMTP module I linked to is a core module and should already be installed, assuming your perl installation is not crippled.


(This post was edited by FishMonger on May 18, 2014, 1:43 PM)


AdrianJ217
Novice

May 18, 2014, 1:46 PM

Post #5 of 7 (11341 views)
Re: [FishMonger] sending email through cgi script [In reply to] Can't Post

I actually tried installing a module for the first time at the cpan prompt but at the final step it got stuck at this:

Server set to: mail.alma.ch
Sending...


AdrianJ217
Novice

May 18, 2014, 2:52 PM

Post #6 of 7 (11313 views)
Re: [AdrianJ217] sending email through cgi script [In reply to] Can't Post

So I tried the Net::SMTP and put all the info in, and I don't get any order but I don't get the email either. I think it's because in the recipient's portion I put the email of the user who filled out the comment form but I'm guessing it has to be the email of the server or something?


Laurent_R
Veteran / Moderator

May 18, 2014, 11:34 PM

Post #7 of 7 (11136 views)
Re: [AdrianJ217] sending email through cgi script [In reply to] Can't Post

Check the documentation on the CPAN site, but you could have something like this:


Code
$smtp->mail("sender"); 
$smtp->to("adressee");
# etc.



(This post was edited by Laurent_R on May 18, 2014, 11:35 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives