动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   Cgi/Perl → 阅读文章

 Windows95/98,NT下如何发EMAIL

作者来源: 
阅读 数 637 人次 , 2006-3-29 4:02:00 


在unix环境下,cgi程序发email都是用sendmail, 在windows95/98,nt没有sendmail,cgi程序如何发邮件呢?其实方法多得很呢!

1.windows环境下发邮件程序

这类程序很多,如blat,sendmail for windows,cgimail等等,它们的用法和unix下的sendmail极其相似,许多unix下cgi程序不用怎么修改就可以在windows下使用.

blat http://www.blat.com (免费)
sendmail for nt http://www.sendmail.com (商业软件)
cgimail http://www.stalkerlab.ch/ (免费)
sendmail for windows http://www.green-bean.com/bcware/sendmail.htm (共享软件)

另外zeng hui朋友(zeng_h@mail.hb.cnpc.com.cn)给我来信说他发现在sambar 4.1中的bin目录下有个mailit.exe文件,其功能与blat.exe相同,而且不用先安装.

2.采用perl模块net::smtp

系统必须支持smtp协议,nt中可安装exchange server

use net::smtp;

{
my $to = 'preston@home.com';
my $from = $env{user} || $env{username};
my $subject = "another test";

my $smtp = net::smtp->new('mail');

$smtp->mail($from);
$smtp->to($to);

$smtp->data();
$smtp->datasend("to: $to\n");
$smtp->datasend("from: $from\n");
$smtp->datasend("subject: $subject\n");
$smtp->datasend("x-mytoken: abcd\n");
$smtp->datasend("\n");
$smtp->datasend("a simple test message\n");
$smtp->dataend() || print "failed send!\n";

$smtp->quit;
}

print "\nmail sent ok\n";
-----

注意"$env{user}"是unix中用的,而$env{username}"是windows nt中用的

3.用outlook发邮件

下面的程序在perl for win32 (build 316)正常运行过
# sender's name and password
#
my $sender = "microsoft outlook"; # profile to be used
my $passwd = "ms exhange settings password"; #profile password

# create a new mapi session
#
use ole;
$session = createobject ole 'mapi.session' || die $!;

my $err = $session->logon($sender, $passwd);
if ($err) {
die "logon failed: $!";
}

# add a new message to the outbox.
#
$msg = $session->outbox->messages->add();

# add the recipient.
#
$rcpt = $msg->recipients->add();
$rcpt->{name} = 'recepient@host.org'; # email address of recepient
$rcpt->resolve();

# create a subject and a body.
#
$msg->{subject} = "test message";
$msg->{text} =
"this is a sample test message. using nt 4.0.

cheers,

mr. email";

# send the message and log off.
#
$msg->update();
$msg->send(0, 0, 0);
$session->logoff();

发送附件和拷贝也可以

$recipient='user@host.com';
$attachment='c:/attach.doc'
$profile="ms exchange settings";#profile name
$mailmeessage="hello";
$password="ms exhange settings password";#profile password
$subject='test';

system("mapisend -u \"$profile\" -p \"$password\" -f \"$attachment\" -s
\"$subject\" -r $recipient -m \"$mailmessage\"")

 本文TagsWindows  windows  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:perl 调试工具 ptkdb 简单介绍
· 下一篇:在Linux下访问MS SQL Server数据库
· perl与mp3
· Perl 的安装与设置
· CGI教程(10)CGI 规范之四
· 用Perl制作留言本实例之三
· CGI教程(11)错误脚本


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077