SMTPsock应用--用php发邮件_PHP教程

WBOY
發布: 2016-07-13 17:23:14
原創
1027 人瀏覽過

server_name可以用php自己的dns解析函数,
以下是核心演示,winNT,mail server is Imail,php3.0.6
需要修改php3.ini打开imap模块,在linux上要编译php --with-IMAP

function send_email ( $to,$from,$subject,$message ){
global $SERVER_NAME;
$fp = fsockopen ( $SERVER_NAME, 25 );
if ( $fp ){

echo "connected";

set_socket_blocking( $fp, false );
$output=fgets($fp,2500);

echo $output;

if (! ereg ( "^220", $output ) ) {
exit();
} else {

echo "talking ";

//set_socket_blocking ( $fp, true );
fputs ( $fp, "HELO $from_domain " );
$output = fgets ( $fp, 2000 );

echo $output;

fputs ( $fp, "MAIL FROM: " );
$output = fgets ( $fp, 2000 );

echo $output;

fputs ( $fp, "RCPT TO: " );
$output = fgets ( $fp, 2000 );

echo $output;

fputs($fp,"DATA ");
fputs($fp,"To: $to ");


fputs($fp,"From: $from ");
fputs($fp,"Subject: $subject ");
fputs($fp,"$message . ");
fputs($fp, "QUIT " );
}
}
fclose($fp);
}

$SERVER_NAME="127.0.0.1";
$from_domain="ws";
$to=" daiger@xifeng.com ";
$from=" wangsu@xifeng.com ";
$subject="test SMTP through PHP 中文";
$message="Send email via PHP smtp connectionsnnnothing happenesn 中文
中文中文";

send_email ( $to,$from,$subject,$message );
echo "ok lah";
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532246.htmlTechArticleserver_name可以用php自己的dns解析函数, 以下是核心演示,winNT,mail server is Imail,php3.0.6 需要修改php3.ini打开imap模块,在linux上要编译php --with-IMAP...
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板