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: Beginner:
How do you use sendmail?

 



SaiyanM
User

Feb 19, 2001, 9:12 AM

Post #1 of 13 (958 views)
How do you use sendmail? Can't Post

How come when someone fills out my guestbook, the e-mail doesn't send? Here is the guestbook cgi



#!/usr/local/bin/perl/

#######################
# Saiyan Menacy Guestbook V 1.1
# Don't Sell this, but feel free to distribute is as much as you like
# as long as this header/message stays intact.
# ChibiGuy Productions 2000
# E-Mail- SaiyanM@hotmail.com
#######################

#####Let's Gather the Variables, shall we?
use CGI qw/:standard/;
$mailp = "/var/qmail/bin/qmail-inject";
$name = param('name');
$email = param('email');
$url = param('url');
$sitename = param('sitename');
$message = param('message');

#####Let's try this e-mail thingamajiggy
sub e_mailPERSON{
open (MAIL,"| /usr/lib/sendmail -t");

print MAIL "To: $email\n";
print MAIL "From: SaiyanM\@hotmail.com\n";
print MAIL "Reply-To: SaiyanM\@hotmail.com\n";

print MAIL "Subject: Thanks For Signing Saiyan Menacy's Guestbook\n\n";
print MAIL "You submitted the following information\n\n";
print MAIL "Name: $name\n";
print MAIL "E-Mail Adress; $email\n";
print MAIL "Site Name: $sitename\n";
print MAIL "Site URL: $url\n";
print MAIL "Message: $message\n\n";
print MAIL "Again, Thanks for signing My Guestbook";
close (MAIL);
}


#####What better to do, than to add the entry?
open(FILE, ">>/data1/virtualave.net/saiyanh/public_html/cgi-bin/guestbook/messages.txt");
print FILE<<END;
<tr>
<td width="20%" bgcolor="silver"><center><font face="Arial" size="1"><a href="mailto:$email">$name</a></center></td>
<td width="20%" bgcolor="silver"><center><font face="arial" size="1"><a href="$url">$sitename</font></center></td>
<td width="40%" bgcolor="silver"><center><font face="arial" size="1"> $message </font></center></td>
</tr>
END
close(FILE);


#####We can't let you leave without us thanking you!
print "Content-type: text/html\n\n";
print <<THANKYOU;



THANKYOU







muinatit
Deleted

Feb 19, 2001, 3:12 PM

Post #2 of 13 (955 views)
Re: How do you use sendmail? [In reply to] Can't Post


Code
open (MAIL, "|/usr/sbin/sendmail -t");

You had a space after the pipe (|).

Jeffrey "muinatit" Lamoureux
muinatit@hotpop.com


SaiyanM
User

Feb 19, 2001, 4:53 PM

Post #3 of 13 (955 views)
Re: How do you use sendmail? [In reply to] Can't Post

nope, that still doesn't work... here is the code again...

<textarea>
#!/usr/local/bin/perl/

#######################
# Saiyan Menacy Guestbook V 1.1
# Don't Sell this, but feel free to distribute is as much as you like
# as long as this header/message stays intact.
# ChibiGuy Productions 2000
# E-Mail- SaiyanM@hotmail.com
#######################

#####Let's Gather the Variables, shall we?
use CGI qw/:standard/;
$name = param('name');
$email = param('email');
$url = param('url');
$sitename = param('sitename');
$message = param('message');
$localtime = localtime;
$IP = $ENV{REMOTE_ADDR};

#####Let's try this e-mail thingamajiggy
sub e_mailPERSON{
open (MAIL,"|/usr/lib/sendmail -t");

print MAIL "To: $email\n";
print MAIL "From: SaiyanM\@hotmail.com\n";
print MAIL "Reply-To: SaiyanM\@hotmail.com\n";

print MAIL "Subject: Thanks For Signing Saiyan Menacy's Guestbook\n\n";
print MAIL "You submitted the following information\n\n";
print MAIL "Name: $name\n";
print MAIL "E-Mail Adress; $email\n";
print MAIL "Site Name: $sitename\n";
print MAIL "Site URL: $url\n";
print MAIL "Message: $message\n\n";
print MAIL "Again, Thanks for signing My Guestbook";
close (MAIL);
}


#####What better to do, than to add the entry?
open(FILE, ">>/data1/virtualave.net/saiyanh/public_html/cgi-bin/guestbook/messages.txt");
print FILE<<END;

<table cellspacing="0" cellpadding="0" border="0" width="700"><tr><td bgcolor="black">

THANKYOU
</textarea>

Does anyone know what the problem is?







(This post was edited by SaiyanM on Feb 19, 2001, 3:57 PM)


wickedxter
User

Feb 19, 2001, 6:46 PM

Post #4 of 13 (952 views)
Re: How do you use sendmail? [In reply to] Can't Post

try this:

open (MAIL,"|/usr/lib/sendmail -t") || &errror("Can't open MAIL");

sub error
{
print "contnet-type: text/html\n\n";
print <<EndHtml;
$_[0]
EndHtml
;
}

This should tell you if the MAIL is even being open and if it's not it will print the error. If no error pops up, then the sendmail has a problem.



Jasmine
Administrator / Moderator

Feb 19, 2001, 10:20 PM

Post #5 of 13 (949 views)
Re: How do you use sendmail? [In reply to] Can't Post

Have you confirmed that /usr/lib/sendmail is the correct path to sendmail?



SaiyanM
User

Feb 20, 2001, 5:34 PM

Post #6 of 13 (939 views)
Re: How do you use sendmail? [In reply to] Can't Post

the error thingy didnt work... ;(. Also i did fix the path to the sendmail program. Yet it still didnt work. Again, here is the program.


#!/usr/local/bin/perl/

#######################
# Saiyan Menacy Guestbook V 1.1
# Don't Sell this, but feel free to distribute is as much as you like
# as long as this header/message stays intact.
# ChibiGuy Productions 2000
# E-Mail- SaiyanM@hotmail.com
#######################

#####Let's Gather the Variables, shall we?
use CGI qw/:standard/;
$name = param('name');
$email = param('email');
$url = param('url');
$sitename = param('sitename');
$message = param('message');
$localtime = localtime;
$IP = $ENV{REMOTE_ADDR};


#####Let's try this e-mail thingamajiggy
sub e_mailPERSON{
open (MAIL,"|/var/qmail/bin/qmail-inject -t");
print MAIL "To: $email\n";
print MAIL "From: SaiyanM\@hotmail.com\n";
print MAIL "Reply-To: SaiyanM\@hotmail.com\n";
print MAIL "Subject: Thanks For Signing Saiyan Menacy's Guestbook\n\n";
print MAIL "You submitted the following information\n\n";
print MAIL "Name: $name\n";
print MAIL "E-Mail Adress; $email\n";
print MAIL "Site Name: $sitename\n";
print MAIL "Site URL: $url\n";
print MAIL "Message: $message\n\n";
print MAIL "Again, Thanks for signing My Guestbook";
close (MAIL);
}


#####What better to do, than to add the entry?
open(FILE, ">>/data1/virtualave.net/saiyanh/public_html/cgi-bin/guestbook/messages.txt");
print FILE<<END;

<table cellspacing="0" cellpadding="0" border="0" width="700"><tr><td bgcolor="black">

THANKYOU






muinatit
Deleted

Feb 20, 2001, 5:47 PM

Post #7 of 13 (937 views)
Re: How do you use sendmail? [In reply to] Can't Post

Well.. I think I know your problem....

You never call the subroutine to send the email! Nothing is going to happen if it never gets called on.

:)

Jeffrey "muinatit" Lamoureux
muinatit@hotpop.com


SaiyanM
User

Feb 20, 2001, 5:53 PM

Post #8 of 13 (937 views)
Re: How do you use sendmail? [In reply to] Can't Post

I dont get what that means. Please explain what i should do



muinatit
Deleted

Feb 20, 2001, 6:15 PM

Post #9 of 13 (935 views)
Re: How do you use sendmail? [In reply to] Can't Post

In your code, insert a call to the sendmail subroutine.

Jeffrey "muinatit" Lamoureux
muinatit@hotpop.com


muinatit
Deleted

Feb 20, 2001, 6:17 PM

Post #10 of 13 (934 views)
Re: How do you use sendmail? [In reply to] Can't Post

Do this...


#!/usr/local/bin/perl/

#######################
# Saiyan Menacy Guestbook V 1.1
# Don't Sell this, but feel free to distribute is as much as you like
# as long as this header/message stays intact.
# ChibiGuy Productions 2000
# E-Mail- SaiyanM@hotmail.com
#######################

#####Let's Gather the Variables, shall we?
use CGI qw/:standard/;
$name = param('name');
$email = param('email');
$url = param('url');
$sitename = param('sitename');
$message = param('message');
$localtime = localtime;
$IP = $ENV{REMOTE_ADDR};

open (MAIL,"|/var/qmail/bin/qmail-inject -t");
print MAIL "To: $email\n";
print MAIL "From: SaiyanM\@hotmail.com\n";
print MAIL "Reply-To: SaiyanM\@hotmail.com\n";
print MAIL "Subject: Thanks For Signing Saiyan Menacy's Guestbook\n\n";
print MAIL "You submitted the following information\n\n";
print MAIL "Name: $name\n";
print MAIL "E-Mail Adress; $email\n";
print MAIL "Site Name: $sitename\n";
print MAIL "Site URL: $url\n";
print MAIL "Message: $message\n\n";
print MAIL "Again, Thanks for signing My Guestbook";
close (MAIL);

#####What better to do, than to add the entry?
open(FILE, ">>/data1/virtualave.net/saiyanh/public_html/cgi-bin/guestbook/messages.txt");
print FILE<<END;

<table cellspacing="0" cellpadding="0" border="0" width="700"><tr><td bgcolor="black">


Jeffrey "muinatit" Lamoureux
muinatit@hotpop.com


SaiyanM
User

Feb 20, 2001, 6:20 PM

Post #11 of 13 (935 views)
Re: How do you use sendmail? [In reply to] Can't Post

lol, Im very new to CGI and i dont know what that means. Can you like give me an example?



Jasmine
Administrator / Moderator

Feb 21, 2001, 1:55 AM

Post #12 of 13 (933 views)
Re: How do you use sendmail? [In reply to] Can't Post

Are you using sendmail or qmail? The code seems to works fine for sendmail, but if you're using a different mail program, then that may require different handling.



muinatit
Deleted

Feb 21, 2001, 3:59 AM

Post #13 of 13 (930 views)
Re: How do you use sendmail? [In reply to] Can't Post

*sigh* You have put the code to send off the email in a subroutine. But you never make a call to the subroutine to do whatever you have in your subroutine!

Somewhere before the code to end the adding of the new entry, you have to call the subroutine with something like this:


Code
&e_mailPERSON;

Okay?

Jeffrey "muinatit" Lamoureux
muinatit@hotpop.com

 
 


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

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