#!/usr/bin/perl
# CGI script that creates a fill-out form
# # and echoes back its values.
#use Date::Manip;
use MIME::Lite; use Net::SMTP; use CGI; use CGI qw/:standard/; $mail_host = '192.168.67.250'; #print "$from_address\n";
print header; print start_html('Duty Report'); print h1('Duty Report'); $method='POST'; $action="test.cgi"; print start_form; # print start_form($method,$action);
print "username:"; print password_field('username','',50,80);
print br; print "duty report:"; print br; print textarea('foo','',15,60); print br; print submit('button_name','submit'); print reset("button","reset"); print end_form; print "\n"; if (param){ $time=localtime(time()); my $body = param('foo'); my $from_address='op@uniforce.net'; #my $from_address=param('username');
#print "from_address:$from_address\n";
open(FILE,"mail.txt")or die "can't open file:$!\n"; $to_address=<FILE>; close FILE; #my $from_address='seven.zhang@uniforce.net';
#my $where=rindex($from_address,"@");
#print "where:$where\n";
#my $name=substr($from_address,0,$where);
#print "to_address:$to_address\n";
#print "body:$body";
$body=$time."\n"."$body"; $name=param('username'); my $subject = "duty report --$name"; #print "subject:$subject\n";
$msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; $msg->attach ( Type => 'TEXT', Data => $body, ) or die "Error adding the text message part: $!\n"; MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send;
print "Email was sent out successfully!\n"; } print end_html; print "\n";
|