msk_0984 has asked for the wisdom of the Perl Monks concerning the following question:
Firstly i would thank all the monks for there support and help in the group by which i have gained a lot of knowledge and which has helped me a lot. I am presently working on sending mail i have seen the sendmail program in the Search and i have got the program using the sendmail that is since i am working on linux systems but wheni am using the Mail::SendMail module in the CGI script i am getting and error i think that i am missing something out here or i have done something wrong here i need ur help monks i have tried in it but i am getting
Software error:
socket failed (Permission denied)
For help, please send mail to the webmaster
(root@localhost), giving this error message and the time and date of the error.
firstly i have tried by using the sendmail pipe there it worked perfectly and i was able to send mail but when i am using the module i am getting the error. And here is my Code plz do help me out i am in my learning stages.
Thanks Sushil#!/usr/bin/perl #Sending A Mail To Single Person use strict; use Mail::Sendmail; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $ob = CGI->new; print $ob->header, $ob->start_html( -title =>" Send An E-mail" ), $ob->h2($ob->i("<u>Sending Mail </u>")), $ob->hr({-color=>"black"}); if ( $ob->param('Submit') ) ## If u Press submit Bu +tton the Get form values & Send Mail { my $ur_name = $ob->param('sender'); my $ur_eid = $ob->param('ur_email'); my $rp_name = $ob->param('recipient'); my $rp_eid = $ob->param('res_email'); my $subjt = $ob->param('subj'); my $mssg = $ob->param('msg'); print $ob->b("Ur : $ur_eid Rps: $rp_eid Subject: $subjt Me +ssage: $mssg <br> "); my %mail = ( To => "$rp_eid" , From => "$ur_eid" , Subject => "$subjt" , Message => " $mssg " ); sendmail(%mail) or die $Mail::Sendmail::error; print "OK. Log says:\n", $Mail::Sendmail::log; # &sendmail( $ob, $ur_eid, $rp_eid, $subjt, $mssg); ### Sen +ding The Mail # # sub sendmail # { # my ($ob, $from, $to, $subject, $message) = @_; # $ENV{PATH} = "/usr/sbin"; # open (MAIL, "|/usr/sbin/sendmail -oi -t") or # &dienice("Can't fork for sendmail: $!\n"); # print MAIL "To: $to\n"; # print MAIL "From: $from\n"; # print MAIL "Subject: $subject\n\n"; # print MAIL "$message\n"; # close(MAIL); # } print <<EndHTML; <h2>Thank You</h2> <p>Thank you for writing!</p> <p>Return to our <a href="">home page</a>.</p> EndHTML } else { print $ob->start_form( -name =>'email' , -method => "POST" , -action =>"http://localhost/cgi-bin/cgiprog +/send_email.cgi"); # printf $ob->b( "user/group:%s/%s</br>\n",scalar getpwuid( $< +), scalar getgrgid( $( ) ); print "<table>"; print "<tr><td>"; print $ob->b($ob->i("Sendername")); print "     "; print $ob->textfield(-name =>'sender',-size=>'25'); print "</td><td>"; print "                 "; print $ob->b($ob->i("Ur Email Id")); print "     "; print $ob->textfield(-name =>'ur_email',-size=>'25'), $ob->br; print "</td></tr></table>"; print $ob->br($ob->br); print "<table>"; print "<tr><td>"; print $ob->b($ob->i("RecipientName")); print "   "; print $ob->textfield(-name =>'recipient' , -size => '25'); print "</td> <td>"; print "                        "; print $ob->b($ob->i(" Email To")); print "   "; print $ob->textfield(-name =>'res_email', -size=>'25'); print "</td></tr>"; print "</table>"; print $ob->br($ob->br), $ob->b($ob->i("Subject")), $ob->textfield(-name =>'subj', -size => '74'), $ob->br($ob->br), $ob->b($ob->i("Message")), $ob->br, $ob->textarea(-name =>'msg', -rows =>'15' , -cols => '80'), $ob->br($ob->br); print "<Center>"; print $ob->submit(-name => "Submit" , -value =>"Send Mail"); print "     "; print $ob->reset; print $ob->end_form; } print $ob->end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using The Mail::Sendmail module in CGI Script
by monkfan (Curate) on Jul 19, 2006 at 07:46 UTC | |
by msk_0984 (Friar) on Jul 19, 2006 at 08:56 UTC | |
|
Re: Using The Mail::Sendmail module in CGI Script
by imp (Priest) on Jul 19, 2006 at 11:35 UTC | |
|
Re: Using The Mail::Sendmail module in CGI Script
by b10m (Vicar) on Jul 19, 2006 at 08:31 UTC | |
by msk_0984 (Friar) on Jul 19, 2006 at 09:00 UTC | |
by marto (Cardinal) on Jul 19, 2006 at 09:08 UTC |