#1 (permalink)  
Old 05-08-2006, 06:38 PM
NevadaSam's Avatar
Registered User
 
Join Date: Apr 2006
Posts: 20
Am I coding Sendmail correctly?

Am I coding Sendmail correctly?

This is the proper location of sendmail on the server I am using. Is this the proper way to code the location in my script.

use /usr/lib/sendmail;

$mail{Smtp} = 'netfirms.com';

I am not really sure if the SMTP address is correct.
This is the program I am working on at this time: http://www.cvtc.netfirms.com/sun.html I can provide the complete code if necessary.
Reply With Quote

  #2 (permalink)  
Old 05-08-2006, 09:13 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,445
What are you trying to do with sendmail? Are you writing your own form processor, or are you using a pre-made form processor? Have you checked the Netfirms support area? They have a very extensive knowledge base.
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #3 (permalink)  
Old 05-08-2006, 09:19 PM
NevadaSam's Avatar
Registered User
 
Join Date: Apr 2006
Posts: 20
Curtiss, what I am trying to do is learn perl. I am being told there are better ways of doing this, but I want to finish the text I am using now.

This is what I am working with. It is correct according to the text book. I just need to set SMTP and code sendmail location correctly.

The HTML:
Code:
<!-- sun.html -->
<HTML>
<HEAD><TITLE>Sun Travel</TITLE>
</HEAD>
<BODY>
<H1>Sun Travel Brochure Request</H1><HR>
<FORM ACTION="http://cvtc.netfirms.com/cgi-bin/sun1.cgi" METHOD=POST>

<TABLE>
<TR><TD>Name:</TD><TD>
    <INPUT TYPE=text NAME=Name SIZE=25></TD></TR>
<TR><TD>E-mail address:</TD><TD>
    <INPUT TYPE=text NAME=Email SIZE=25></TD></TR>
</TABLE>

<BR><INPUT TYPE=submit VALUE="Send Me A Brochure">
</FORM></BODY></HTML>
sun1.cgi - No problem here:
Code:
#!/usr/bin/perl
#sun1.cgi - displays a dynamic Web page listing available brochures
print "Content-type: text/html\n\n";
use CGI qw(:standard -debug);

#prevent Perl from creating undeclared variables
use strict;

#declare and assign values to variables
my ($name, $email);
$name = param('Name');
$email = param('Email');

#create Brochure Listing form
print "<HTML>\n";
print "<HEAD><TITLE>Sun Travel</TITLE></HEAD>\n";
print "<BODY>\n";
print "<FORM 
        ACTION='http://cvtc.netfirms.com/cgi-bin/sun2.cgi' 
        METHOD=POST>\n";

print "<!hidden fields>\n";
print "<input type=hidden name=H_name Value='$name'>\n";
print "<input type=hidden name=H_email Value='$email'>\n";


print "<H1>Sun Travel Brochure Listing</H1><HR>\n";
print "<H3>Thank you, $name.<BR>\n";
print "Please select from our list of brochures:</H3>\n";
print "<SELECT NAME=Brochure SIZE=4>\n";
print "<OPTION VALUE=Aruba SELECTED>Aruba\n";
print "<OPTION VALUE=California>California\n";
print "<OPTION VALUE=Florida>Florida\n";
print "<OPTION VALUE=Jamaica>Jamaica\n";
print "</SELECT><BR><BR>\n";

print "<INPUT TYPE=submit VALUE=Submit>\n";
print "</FORM></BODY></HTML>\n";

sun2.cgi - This is where it hangs up at:
Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI qw(:standard -debug);

/usr/lib/sendmail;
use strict;

my ($brochure, $name, $email, $msg, %mail);

#assign input items to variables
$brochure = param('Brochure');
$name = param('H_name');
$email = param('H_email');

#create message
$msg = "Thank you, $name. We have received your request for a \n";
$msg = $msg . "brochure on $brochure. We will mail the brochure \n";
$msg = $msg . "to you as soon as possible.";

#create Web page acknowledgment
print "<HTML>\n";
print "<HEAD><TITLE>Sun Travel</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H1>Sun Travel</H1><HR>\n";
print "<H2>$msg</H2>\n";
print "</BODY></HTML>\n";

#send e-mail acknowledgment
$mail{To} = $email;
$mail{From} = 'nevadasam@gmail.com';
$mail{Subject} = 'Travel Information';
$mail{Smtp} = 'netfirms.com';
$mail{Message} = $msg;
sendmail (%mail);
Reply With Quote
  #4 (permalink)  
Old 05-09-2006, 11:26 AM
Deadeye's Avatar
Moderator
 
Join Date: Aug 2005
Location: San Diego, CA
Posts: 274
Send a message via MSN to Deadeye
here are a few things wrong with your script. I'm not sure if this will hang it up, but are bad programming practices inside PERL.

Code:
$msg = "Thank you, $name. We have received your request for a \n";
you should have a dot(.) to separate quotes and variables, so you will want
Code:
$msg = "Thank you, " . $name . ". We have received your request for a \n";
The same goes for this line as well
Code:
print "<H2>$msg</H2>\n";
Code:
print "<H2>" . $msg . "</H2>\n";
Other then that things look correct. If you are not getting any errors on your script but the email is not being sent you need to make sure the hash, which in your case is %mail, names are correct. When you are passing to a function like send mail the hash name could be smtp, not Smtp, and since PERL is case sensitive that will make your script not work all together.

Wesley
Reply With Quote
  #5 (permalink)  
Old 05-09-2006, 11:48 AM
NevadaSam's Avatar
Registered User
 
Join Date: Apr 2006
Posts: 20
Those are probably so good habbits my text does not teach. That is why I am book hunting. Thanks for your recomendation in the other post.
Reply With Quote
  #6 (permalink)  
Old 05-09-2006, 12:20 PM
Deadeye's Avatar
Moderator
 
Join Date: Aug 2005
Location: San Diego, CA
Posts: 274
Send a message via MSN to Deadeye
Quote:
Originally Posted by NevadaSam
Those are probably so good habbits my text does not teach.
I could go on and on about good coding standards that you would get tired is reading what I write

Quote:
Originally Posted by NevadaSam
Thanks for your recomendation in the other post.
No problem, I'm just glad to help. I've been writing PERL since I was about 18.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sendmail and Exchange Email Accounts curtiss Servers 3 04-30-2006 11:19 AM
ASCII coding problem HELP!!! psi3000 Programming and Scripting 1 02-28-2006 11:49 AM
Slicing and Coding this layout. Panda Programming and Scripting 0 07-12-2005 04:55 PM
I need help with coding JavaScript DHTML Collapsible List Amerex Programming and Scripting 1 02-09-2005 06:51 PM


All times are GMT -5. The time now is 05:31 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter