software products and customization
Contact: support@xuebrothers.net Back to Main Page

The CGI Source Codes for SMTP over HTTP

The source codes below are for demo purpose only. Different systems may requires different implementations.


#!/usr/bin/perl
use CGI;
use Digest::MD5 qw(md5_hex);

my $req = new CGI; 
my $from=$req->param("from"); 
if($from eq "")
{
	Error('403', 'Error From');
}

my $to=$req->param("to"); 
if($to eq "")
{
	Error('403', 'Error To');
}

my $pwd1 = $req->param("pwd"); 
my $pwd2= "mycgipassword";
if($pwd1 ne $pwd2)
{
	Error('403', 'Error Password');
}

my $data=$req->param("data"); 
if($data eq "")
{
	Error('403', 'Error Data');
}

my $fh_data = $req->upload("data");
open(MAIL, "|/usr/sbin/sendmail -t");
while (<$fh_data>)
{ 
	print MAIL; 
} 
close(MAIL);
close($fh_data);

print "Content-type: text/plain\n\n";
print "OK";

sub Error
{
	print "Status: $_[0]\n";
	print "Content-type: text/plain\n\n";
	print $_[1];
	exit;
}