?? smtp.cgi
字號:
#------------------------------------------------------#
# 本程序為Yuzi工作室提供 #
# Yuzi論壇3000(BBS3000)v4.00 #
######################---------------------------------#
## 以下部分不需修改 ##
######################
use Socket;
$smtp =~ s/^\s+//g;
$smtp =~ s/\s+$//g;
$smtp_port = 25 if (($smtp_port !~ /^\d+$/)||($smtp_port eq ""));
my ($a, $i, $name, $aliases, $proto, $type, $len, $thataddr);
my $AF_INET = 2;
my $SOCK_STREAM = 1;
my $SOCKADDR = 'S n a4 x8';
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $smtp_port) = getservbyname($smtp_port, 'tcp') unless ($smtp_port =~ /^\d+$/);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($smtp);
my $this = pack($SOCKADDR, $AF_INET, 0, $thisaddr);
my $that = pack($SOCKADDR, $AF_INET, $smtp_port, $thataddr);
socket(S, $AF_INET, $SOCK_STREAM, $proto);
bind(S, $this);
connect(S, $that);
select(S);
$| = 1;
select(STDOUT);
$a = <S>;
if ($a !~ /^2/)
{
close(S);
undef $|;
return 0;
}
if ($smtp_user ne "" && $smtp_psd ne ""){
print S "EHLO localhost\n";
$a = <S>;
print S "AUTH LOGIN\n";
$a = <S>;
my $encode_smtpuser = Base64encode($smtp_user);
print S "$encode_smtpuser\n";
$a = <S>;
my $encode_smtppass = Base64encode($smtp_psd);
print S "$encode_smtppass\n";
$a = <S>;
}else{
print S "HELO $ENV{REMOTE_ADDR}\r\n";
$a = <S>;
print S "MAIL FROM: <$from>\r\n";
$a = <S>;
}
print S "MAIL FROM: <$from>\r\n";
$a = <S>;
if ($a !~ /^2/)
{
close(S);
undef $|;
return 0;
}
$sendto=~ s/\;/\,/g;
$all_recipients = $sendto;
@Recipients = split(/[\,]/,$all_recipients);
while($recipient = shift(@Recipients)){
if($recipient =~ /([^\s<]+@[^\s\r,>]+)/){
$recipient = '<' . $1 . '>';
print S "RCPT TO: $recipient\r\n";
$a = <S>;
if ($a !~ /^2/)
{
close(S);
undef $|;
return 0;
}
}
}
print S "DATA\n";
$Message = qq|To:$sendto\r\n|;
$Message .= qq|From:$adminmail\r\n|;
$Message .= qq|Subject:$subject\r\n|;
$Message .= "$message";
$Message =~ s/\r\n?/\n/g;
print S $Message;
print S "\n";
print S "\n\n";
print S ".\n";
$a = <S>;
print S "QUIT\n";
$a = <S>;
close(S);
undef $|;
return 1;
sub Base64encode
{
my $res = "";
while ($_[0] =~ /(.{1,45})/gs)
{
$res .= substr(pack('u', $1), 1);
chop($res);
}
$res =~ tr| -_|A-Za-z0-9+/|;
my $padding = (3 - length($_[0]) % 3) % 3;
$res =~ s/.{$padding}$/'=' x $padding/e if ($padding);
return $res;
}
1;
######################### END OF SCRIPT #########################
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -