Hi Friends
I have a requirement to where my cgi program has to send an email when the "Submit" button is pressed.
Here is my cgi program, which has a text field to enter the username and a submit button.
#!C:/Perl/bin/Perl.exe
use strict;
use CGI qw(:standard);
use CGI;
use check;
my $q = new CGI;
print $q->header("text/html");
my $action = param("action");
print button();
sub button {
return <<EOF;
<html>
<head>
<title></title>
</head>
<body bgcolor="#95CBE9">
<form>
<TABLE BORDER=0 align="center" cellpadding="20">
<TR>
<TD>User Name</TD>
<TD>
<INPUT type=text size="40" name="username" value=""/>
</TD>
</TR>
<TR>
</TR>
</TABLE>
<br><br><br>
<p>
<center>
<input type="submit" value="Submit" onClick=?????>
</p>
</form>
</body>
</html>
EOF
}
What I need to do is when the user hits the submit button an email has to be sent from Windows platform. I did a bit of googling and found out the perl script to send the mail as follows. This uses Net::SMTP
use Net::SMTP;
my $smtpserver = 'xxx.xxx.xxx.xxx';
my $smtpuser = 'username';
my $fromemail = 'someone@somewhere.com';
my $smtp = Net::SMTP-> new($smtpserver, Timeout => 10);
$smtp-> mail($smtpuser);
$smtp-> to('someoneelse@somewhere.cz');
$smtp-> data();
$smtp-> datasend("To: blblb\@blblbl.cz\n");
$smtp-> datasend("From: psmejkal\@tesco.cz\n");
$smtp-> datasend("\n");
$smtp-> datasend("test\n");
$smtp-> dataend();
$smtp-> quit;
But I have no idea on how to integrate it with the cgi script.
Any help would be really appreciated.
~Rose