Chinaunix首页 | 论坛 | 博客
  • 博客访问: 484887
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2008-06-24 17:16:49


#!/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";

阅读(256) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~