dedecms织梦内容管理系统    
首页 | java | C/C++ | PHP | 操作系统 | ajax | 脚本编程 | 安全技术 | 本站下载页 | 专题 | QQ群 | 测试中心 | 会员中心 | 积分规则
  当前位置:主页>脚本编程>perl>文章内容
cgi中的邮件发送器2
来源: 作者:
  #读入附件信息

  if($AttachNum ne ""){ @AttachFileName=split(/;/,$AttachFile);}

  use Sender;

  $Send = new Sender({from=>$From,

  smtp=>$SmtpSever});

  if ( !( ref $Sender) =~ /Sender/i ) {

  die $Sender::Error;

  }

  $Send->OpenMultipart({to=>$To,

  subject=>$Subject,

  replyaddr=>$Cc});

  $Send->Body;

  $Send->SendLine($MailContent);

  if ($AttachNum ne "") {

  for ( $i=1; $i<=$AttachNum; $i++) {

  $Send->SendFile({description=>'邮件附件',

  encoding=>'Base64',

  disposition=>"attachment;filename=$AttachFileName[$i-1]",

  file=>"$AttachDir$AttachFileName[$i-1]"});

  }

  }

  $Send->Close;

  #&print_head;

  #print<<"EOF";

  #$From,$To,$Subject,$Cc,$Bcc,$AttachFile,$MailContent,$AttachNum,$SmtpSever

  #EOF

  #&print_foot;

  if ($Send->{'error'} <0 ) {

  mail_error('i',$Send->{'error'});

  }

  &ShowMailSuccess;

  }

  sub mail_error #3/24/00 4:24PM

  {

  my ($user,$errorCode)=@_;

  &print_head;

  ($errorCode eq -1) and print "SMTP错误代码:-1";

  ($errorCode eq -2) and print "SMTP错误代码:-2";

  ($errorCode eq -3) and print "SMTP错误代码:-3";

  ($errorCode eq -4) and print "SMTP错误代码:-4";

  ($errorCode eq -5) and print "SMTP错误代码:-5";

  ($errorCode eq -6) and print "SMTP错误代码:-6";

  ($errorCode eq -7) and print "SMTP错误代码:-7";

  ($errorCode eq -8) and print "SMTP错误代码:-8";

  ($errorCode eq -9) and print "SMTP错误代码:-9";

  ($errorCode eq -10) and print "SMTP错误代码:-10";

  ($errorCode eq -11) and print "SMTP错误代码:-11";

  ($errorCode eq -12) and print "SMTP错误代码:-12";

  &print_foot;

  exit;

  }

  ############################################################################

  sub ShowMailSuccess #4/15/00 7:46PM

  ############################################################################

  {

  &print_head;

  print<<"EOF";

  成功发信

  EOF

  &print_foot;

  exit;

  } ##ShowMailSuccess

  ############################################################################

  sub AttachFile #4/13/00 4:04PM

  ############################################################################

  {

  &ReadInput;

  ($AttachNum >= 3) and (ShowAttachForm($From,$To,$Subject,$Cc,$Bcc,$AttachFile,$MailContent,$AttachNum,$AttachFile1,$AttachFile2,$AttachFile3,1));

  my $AbsName = $NewFile;

  $AbsName =~ s!^.*(\\|\/)!!;

  open (FILE, ">$AttachDir$AbsName");

  binmode(FILE);

  while (my $bytesread = read($NewFile, my $buffer, 1024)) {

  print FILE $buffer;

  }

  close (FILE);

  $AttachFile .= $AbsName.';';

  $AttachNum += 1;

  if ($AttachNum eq 1) {$AttachFile1=$AbsName;}

  if ($AttachNum eq 2) {$AttachFile2=$AbsName;}

  if ($AttachNum eq 3) {$AttachFile3=$AbsName;}

  ShowAttachForm($From,$To,$Subject,$Cc,$Bcc,$AttachFile,$MailContent,$AttachNum,$AttachFile1,$AttachFile2,$AttachFile3,0);

  }

  ############################################################################

  sub ShowMailForm #4/13/00 4:50PM

  ############################################################################

  {

  #my ($From,$To,$Subject,$Cc,$Bcc,$AttachFile,$MailContent,$AttachNum) = @_;

  &ReadInput;

  &print_head;

  print<<"EOF";

  <form action="$ENV{'SCRIPT_NAME'}" align="center" method="post">

  <input type="hidden" name="attachnum" value="$AttachNum"><input type="hidden" name="attachfile1"

  value="$AttachFile1"><input type="hidden" name="attachfile2" value="$AttachFile2"><input

  type="hidden" name="attachfile3" value="$AttachFile3">

  <table border="0" cellpadding="0" cellspacing="0" width="69%">

  <tr>

  <td width="22%" align="right" bgcolor="#008000"><font color="#FFFFFF">发信人:</font></td>

  <td width="78%" bgcolor="#F0FCC0"><input type="text" name="from" value="$From" size="38"></td>

  </tr>

  <tr>

  <td width="22%" align="right" bgcolor="#008000"><font color="#FFFFFF">收件人:</font></td>

  <td width="78%" bgcolor="#F0FCC0"><input type="text" name="to" value="$To" size="38"></td>

  </tr>

  <tr>

  <td width="22%" align="right" bgcolor="#008000"><font color="#FFFFFF">主题:</font></td>

  <td width="78%" bgcolor="#F0FCC0"><input type="text" name="subject" value="$Subject" size="38"></td>

  </tr>

  <tr>

  <td width="22%" align="right" bgcolor="#008000"><font color="#FFFFFF">抄送:</font></td>

  <td width="78%" bgcolor="#F0FCC0"><input type="text" name="cc" value="$Cc" size="38"></td>

  </tr>

  <tr>

  <td width="22%" align="right" bgcolor="#008000"><font color="#FFFFFF">暗送:</font></td>

  <td width="78%" bgcolor="#F0FCC0"><input type="text" name="bcc" value="$Bcc" size="38"></td>

  </tr>

  <tr>

  <td width="22%" align="right" bgcolor="#008000"><font color="#FFFFFF">附件:</font></td>

  <td width="78%" bgcolor="#F0FCC0"><input type="text" name="attachfile" value="$AttachFile"

  size="38"></td>

  </tr>

  <tr>

  <td width="22%" align="right">

  </td>

  <td width="78%" valign="bottom" align="left" ><input alt="发信" name="mailbutton"

  src="$MailButton" type="image" > <input alt="附件" name="attachbutton"

  src="$AttachButton" type="image" >

  </td>

  </tr>

  <tr>

  <td width="22%" align="right">邮件正文:</td>

  <td width="78%"></td>

  </tr>

  <tr>

  <td width="100%" colspan="2" align="center"><textarea rows="11" name="mailcontent" cols="47">$MailContent</textarea></td>

  </tr>

  </table>

  </form>

  EOF

  &print_foot;

  } ##ShowMailForm
本文来自:http://www.linuxpk.com/2945.html

上一篇:cgi中的邮件发送器1   下一篇:C++中的fstream类用于文件的I/O操作
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·使用Perl修改Linux文件
·Perl基础指南
·Python的几个文字处理技巧
·Perl DBI连接MySQL数据库
·Perl DBI 入门
·Windows2003+Apache+mod_perl安
·Perl/TkFAQ如何使用某个组件来完
·用Perl语言进行Socket编程
·操作系统比对脚本[inststuff.pl]
·测试mod_perl模块
·Perl聊天室实例
·cgi中的邮件发送器1
  相关文章
·cgi中的邮件发送器1
·Perl聊天室实例
·测试mod_perl模块
·操作系统比对脚本[inststuff.pl]
·用Perl语言进行Socket编程
·Perl/TkFAQ如何使用某个组件来完
·Windows2003+Apache+mod_perl安
·Perl DBI连接MySQL数据库
·Perl DBI 入门
·Python的几个文字处理技巧
·Perl基础指南
·使用Perl修改Linux文件
  相关信息
copy right @ 百家拳软件项目研究室 2007 辽ICP备07011763