文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>SMTPsock应用--用php发邮件

SMTPsock应用--用php发邮件

时间:2007-02-17  来源:PHP爱好者

server_name可以用php自己的dns解析函数,

以下是核心演示,winNT,mail server is Imail,php3.0.6

需要修改php3.ini打开imap模块,在linux上要编译php --with-IMAP

<?php

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_domainn" );
$output = fgets ( $fp, 2000 );

echo $output;

fputs ( $fp, "MAIL FROM: <$from>n" );
$output = fgets ( $fp, 2000 );

echo $output;

fputs ( $fp, "RCPT TO: <$to>n" );

$output = fgets ( $fp, 2000 );

echo $output;

fputs($fp,"DATAn");

fputs($fp,"To: $ton");

fputs($fp,"From: $fromn");

fputs($fp,"Subject: $subjectnn");

fputs($fp,"$messagenn.n");

fputs($fp, "QUITn" );

}

}

fclose($fp);

}

$SERVER_NAME="127.0.0.1";

$from_domain="ws";

$to=" [email protected] ";

$from=" [email protected] ";

$subject="test SMTP through PHP 中文";

$message="Send email via PHP smtp connectionsnnnothing happenesn 中文

中文中文";

send_email ( $to,$from,$subject,$message );

echo "ok lah";

?>
php爱好者站 http://www.phpfans.net Linux|Apache|IIS.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载