当前位置:51VIP源码软件音乐MTV下载联盟网络学院程序开发其它相关 → cgi中的邮件发送器2

cgi中的邮件发送器2

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-6-1 0:07:56 我要发布文章
  #读入附件信息

  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