473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Testing 'Form-to-Email CGI'

135 100+
I'm testing out an .cgi example to send an email, however I'm not sure where the sendmail program lives on my Windows o/s. The example states that I need to figure out where sendmail program lives on my system, how do I this?

Please see part of the code below:
Expand|Select|Wrap|Line Numbers
  1. $mailprog = '/usr/sbin/sendmail';
  2. open (MAIL, "|$mailprog -t)
I know using sendmail.pm / use sendmail module is easier however I would like to try this example out without using modules.

Thank you
Sep 17 '07 #1
17 2927
KevinADC
4,059 Expert 2GB
normally there is no sendmail application installed on windows. You can see by the path that it is not windows:

/usr/sbin/sendmail

You could create a /usr/sbin/ directory on your windows computer but you would also need sendmail.exe installed. There might be a sendmail.exe for windows for all I know but you will have to search for it.
Sep 17 '07 #2
numberwhun
3,509 Expert Mod 2GB
normally there is no sendmail application installed on windows. You can see by the path that it is not windows:

/usr/sbin/sendmail

You could create a /usr/sbin/ directory on your windows computer but you would also need sendmail.exe installed. There might be a sendmail.exe for windows for all I know but you will have to search for it.
There is definitely more than one option depending on which software you want to install.

Regards,

Jeff
Sep 17 '07 #3
patelxxx
135 100+
Guy's,

most of the perl books on the market I've seen and also the one I'm using tend to assume user is using Unix/Linix. So I've deceided to install Linix.

Would you guy's recommend me installing RED HAT Linix? Can I do Unix / shell programming using RED HAT Linix?

Or would you recommend some other Unix / Linix O/S?

Cheers
Sep 18 '07 #4
numberwhun
3,509 Expert Mod 2GB
Guy's,

most of the perl books on the market I've seen and also the one I'm using tend to assume user is using Unix/Linix. So I've deceided to install Linix.

Would you guy's recommend me installing RED HAT Linix? Can I do Unix / shell programming using RED HAT Linix?

Or would you recommend some other Unix / Linix O/S?

Cheers
Which distribution that you use is more of a personal preference, but it sounds like you are just beginning (prepare for the vertical learning curve if you don't know Unix)
(BTW, its spelled "Linux").

Instead of Red Hat, which you have to pay to get updates from, I would choose Fedora, which is the Red Hat spin-off. Yes, you can do shell programming with ANY unix based environment.

Also, just because a book assumes Linux or Unix, does not mean that you cannot learn to code on Windows. The Perl code, with the exception of the shebang line, is pretty much the same.

Regards,

Jeff
Sep 18 '07 #5
patelxxx
135 100+
Regarding the sendmail.exe which I've downloaded and placed in the following location: c:/perl/bin/sendmail.exe- (for the sendmail conf file)

How do I find my SMTP server name? Currently i've set it to: smtp.mysite.com

Also what is my default domain? Currently I've set this to: localhost

My mail.cgi has the following line:

[CODE:perl]$mailprog = '/perl/bin/sendmail.exe';[/code]
also tried 'c:/perl/bin/sendmail.exe'

My shebang line in mail.cgi:

[CODE:perl]#!c:/perl/bin/perl.exe[/code]

I'm getting no error when sending the mail via sendmail, however i'm not receiving the mail, hence just wanted to confirm the above info.

Cheers

p.s. if all above info seems correct, can I get someone to check my mail.cgi file?
Sep 18 '07 #6
KevinADC
4,059 Expert 2GB
personally when I want to test a perl script using sendmail I just use an online account that is setup already. Pretty much everything else I can code and test on windows and my local apache installation.
Sep 19 '07 #7
patelxxx
135 100+
Can someone kindly check my sending email script (mail.cgi and mail.html), this time I am running this on Linux platform. Error message I get: Internal Server Error.

My scripts below (mail.cgi):

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. print "Content-type: text/html\n\n";
  4. print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 
  5. Final//EN\">\n<HEAD>\n<TITLE>email program</TITLE>\n</HEAD>\n<BODY>\n";
  6.  
  7. print "Perl CGI EMAIL testing script\n<br><br><br>";
  8.  
  9. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  10. @pairs = split(/&/, $buffer);
  11. foreach $pair (@pairs) {
  12.     ($name, $value) = split(/=/, $pair);
  13.     $value =~ tr/+/ /;
  14.     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  15.     $FORM{$name} = $value;
  16. }
  17. $mailprog = '/usr/sbin/sendmail';
  18.  
  19. $recipient = 'patelxx@hotmail.com';
  20.  
  21. open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
  22.  
  23. print MAIL "To: $recipient\n";
  24.  
  25. print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
  26.  
  27. print MAIL "Subject: Form Data\n\n";
  28.  
  29. foreach $key (keys(%FORM)) {
  30.     print MAIL "$key = $FORM{$key}\n";
  31. }
  32.  
  33. close(MAIL);
  34.  
  35. print <<EndHTML;
  36. <h2>Thank You</h2>
  37. Thank you for writing.  Your mail has been delivered.<p>
  38. Return to our <a href="index.html">home page</a>.
  39. </body></html>
  40. EndHTML
  41.  
  42. sub dienice {
  43.     ($errmsg) = @_;
  44.     print "<h2>Error</h2>\n";
  45.     print "$errmsg<p>\n";
  46.     print "</body></html>\n";
  47.     exit;
  48. }
My HTML script below (mail.html):

[HTML]<html><head><title>Mail.html</title></head>
<body>

<form action="/cgi-bin/mail.cgi" method="POST">
<pre>
Your Name: <input type="text" name="name">
Email Address: <input type="text" name="email">
Age: <input type="text" name="age">
Favorite Color: <input type="text" name="favorite_color">
</pre>
<input type="submit" value="Send">
<input type="reset" value="Clear Form">
</form>

</body>
</html>[/HTML]
Sep 27 '07 #8
patelxxx
135 100+
Error Log:

[error] [client 81.77.86.109] File does not exist: /home/patelxx/public_html/500.shtml, referer: http://www.patelxx.com/mail.html
Sep 28 '07 #9
eWish
971 Expert 512MB
Change:
Expand|Select|Wrap|Line Numbers
  1. print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 
  2. Final//EN\">\n<HEAD>\n<TITLE>email program</TITLE>\n</HEAD>\n<BODY>\n";
To:
Expand|Select|Wrap|Line Numbers
  1. print qq~<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 
  2. Final//EN\">\n<HEAD>\n<TITLE>email program</TITLE>\n</HEAD>\n<BODY>\n ~;
Then add this line to your script after the first line to get the error's to print to the browser. This is a great tool for debugging. Then we can go from there.
Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw/fatalsToBrowser/; 
Sep 28 '07 #10
patelxxx
135 100+
This is the error I get after the change you told me to make, it the same error(i.e. I have also changed the permissions tto 755 still not luck):

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@patelxx.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


--------------------------------------------------------------------------------

Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.patelxx.com Port 80
Sep 28 '07 #11
eWish
971 Expert 512MB
When you uploaded it to your server, did you do it in ascii mode? Did you set the permissions to 755?

Also add these lines to you code.
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
Sep 28 '07 #12
patelxxx
135 100+
The file being uploaded is in ASCII mode and also the chmod is set to 755. I still get the error as stated previously.

Could you kindly test or check the script (mail.cgi and mail.html). Cheers.
Sep 28 '07 #13
eWish
971 Expert 512MB
The file being uploaded is in ASCII mode and also the chmod is set to 755. I still get the error as stated previously.
I missed that part of your post. Well if you use the strict pragma then the errors give are because you did have not declared your $variables. If you don't use the strict prarams then the script for me did not cause any errors.

I recommend that you use the strict pragma and declare the varables.
Sep 28 '07 #14
patelxxx
135 100+
if you can just look at the following link on my site:

http://www.patelxx.com/mail.html


cheers
Sep 28 '07 #15
KevinADC
4,059 Expert 2GB
the shebang line might be wrong. Looking at the html code will not help determine why you get a 500 ISE.
Sep 29 '07 #16
eWish
971 Expert 512MB
Troubleshooting Perl CGI scripts
Sep 29 '07 #17
numberwhun
3,509 Expert Mod 2GB
Troubleshooting Perl CGI scripts
Excellent link eWish! Thanks for sharing!!!

Regards,

Jeff
Sep 29 '07 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Filips Benoit | last post by:
Hi, TBL_CONTACT_PERSON CNTP_ID (auto) CNTP_LAST_NAME (required = yes) CNTP_FUNCTION (required = no) CNTP_..... (all required = no) FRM_CONTACT_PERSON_ADD_NEW Property DATA ENTRY = YES
2
by: JSMiami | last post by:
The switchboard has a way of opening forms in either Add mode or in Edit mode. Is there anyway of testing for that mode in VB code? If not is there a way of testing (within a subform) if there is a...
0
by: Bruno Piovan | last post by:
Testing, testing, 1, 2, 3... Testing....
11
by: D. Yates | last post by:
Hi, In an effort to improve my own code and try to teach others that I work with that unit testing IS MANDATORY. I'm interested in examples of unit testing that other people are using. How...
0
by: simonkatich90 | last post by:
Material on Win runner, Load Testing, Unit Testing and Much More... Articles, Methodologies, Q&A on Software Testing Techniques & Quality Assurance: ...
0
by: xiare.austin | last post by:
In depth articles and automated tools, Q & A every thing you would need for Software testing provided at the link below http://it-mystic.com/testing-mystic/software-testing.htm
0
by: hubs.belo | last post by:
I have found an excellent site on Software Testing, the site provides in depth material on what and how is software testing, along with complete details of Win Runner / Load Runner. The site has a...
1
by: Software Engineer | last post by:
Learn Software Testing http://trailfire.com/frank/marks/34684 If you are a software QA engineer or someone interested in software testing, this trail is for you. It covers software testing...
0
by: jasonjones.itmaster | last post by:
A large variety of testing tools available. Providing in depth analysis for software testing tools that how you can expert in using any testing tool for software testing. Have a look and take...
2
by: mo.sparrow | last post by:
Typemock Isolator – A powerful mocking framework for .NET unit testing and Test Driven Development (in Visual Studio). http://www.typemock.com/learn_about_typemock_isolator.html NUnit - A...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.