📄 ebmail.inc.php
字号:
<?php
function ebmail( $to, $from, $subject, $message )
{
global $CONF;
$owner_m_smtp = $CONF['owner_m_smtp'];
$owner_m_user = $CONF['owner_m_user'];
$owner_m_pass = $CONF['owner_m_pass'];
$owner_m_check = $CONF['owner_m_check'];
$owner_m_mail = $CONF['owner_m_mail'];
$ownersys = $CONF['ownersys'];
if ( $ownersys == "1" )
{
mail( $to, $subject, $message, "From: {$from}\nReply-To: {$from}\nX-Mailer: PHP/".phpversion( ) );
}
else if ( $ownersys == "2" )
{
send22( $to, $from, $subject, $message );
}
}
function send22( $to, $from, $subject, $message )
{
global $CONF;
$owner_m_smtp = $CONF['owner_m_smtp'];
$owner_m_user = $CONF['owner_m_user'];
$owner_m_pass = $CONF['owner_m_pass'];
$owner_m_check = $CONF['owner_m_check'];
$owner_m_mail = $CONF['owner_m_mail'];
$ownersys = $CONF['ownersys'];
$smtp = $owner_m_smtp;
$check = $owner_m_check;
if ( $check )
{
$username = $owner_m_user;
$password = $owner_m_pass;
}
$s_from = $owner_m_mail;
$fp = fsockopen( $smtp, 25, $errno, $errstr, 20 );
if ( !$fp )
{
return "联接服务器失败".( 49 );
}
set_socket_blocking( $fp, true );
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != 220 )
{
return "错误信息:".$lastmessage.( 53 );
}
$yourname = "YOURNAME";
if ( $check == "1" )
{
$lastact = "EHLO ".$yourname."\r\n";
}
else
{
$lastact = "HELO ".$yourname."\r\n";
}
fputs( $fp, $lastact );
$lastmessage == fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != 220 )
{
return "错误信息{$lastmessage}".( 62 );
}
while ( true )
{
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 3, 1 ) != "-" || empty( $lastmessage ) )
{
break;
}
}
if ( $check == "1" )
{
$lastact = "AUTH LOGIN"."\r\n";
fputs( $fp, $lastact );
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != 334 )
{
return "错误信息{$lastmessage}".( 76 );
}
$lastact = base64_encode( $username )."\r\n";
fputs( $fp, $lastact );
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != 334 )
{
return "错误信息{$lastmessage}".( 81 );
}
$lastact = base64_encode( $password )."\r\n";
fputs( $fp, $lastact );
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != "235" )
{
return "错误信息{$lastmessage}".( 86 );
}
}
$lastact = "MAIL FROM: <".$s_from.">\r\n";
fputs( $fp, $lastact );
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != 250 )
{
return "错误信息{$lastmessage}".( 93 );
}
$lastact = "RCPT TO: <".$to.">\r\n";
fputs( $fp, $lastact );
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != 250 )
{
return "错误信息{$lastmessage}".( 99 );
}
$lastact = "DATA\r\n";
fputs( $fp, $lastact );
$lastmessage = fgets( $fp, 512 );
if ( substr( $lastmessage, 0, 3 ) != 354 )
{
return "错误信息{$lastmessage}".( 105 );
}
$head = "Subject: {$subject}\r\n";
$message = $head."\r\n".$message;
$head = "From: {$from}\r\n";
$message = $head.$message;
$head = "To: {$to}\r\n";
$message = $head.$message;
$message .= "\r\n.\r\n";
fputs( $fp, $message );
$lastact = "QUIT\r\n";
fputs( $fp, $lastace );
fclose( $fp );
return 0;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -