Home > Backend Development > PHP Tutorial > NT下基于邮件服务软件(IMAIL)的邮件发送程序--(网络版)_PHP

NT下基于邮件服务软件(IMAIL)的邮件发送程序--(网络版)_PHP

WBOY
Release: 2016-06-01 12:42:39
Original
1199 people have browsed it

IMail

如果你无法在服务器上安装IMAIL,那只能通过socket来发送邮件。但是如果你幸运的话,也可以用163/sina的

smtp服务。

例程如下(原程序由马毅兄提供):


Mail Form anywhere



if($sendit)
{
$smtpserver="202.110.200.242" ;        //将此处设为IMAIL的IP
echo "
" ;<br>
$fp = fsockopen($smtpserver, 25, &$errno, &$errstr, 10) ; //连接smtp服务器,端口25<br>
if(!$fp) die("wrong open smtp SERVER") ;<br>
$hostreplay=fgets($fp,128);<br>
//if (!strstr($hostreplay,"220")) die(" can n't receive the 220 answer ") ;<br>
$smailname=strstr(ltrim($hostreplay),"220 ") ;<br>
$smailname=substr($smailname,0,strpos($smailname,".")) ;<br>
//echo "\nsmailname:$smailname\n" ;<br>
fputs($fp,"$smailname \n") ;<br>
$hostreplay=fgets($fp,128);<br>
//if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;<br>
<br>
fputs($fp,"MAIL FROM: \n") ;<br>
$hostreplay=fgets($fp,128) ;<br>
if (!strstr($hostreplay,"250")) {<br>
fputs($fp,"MAIL FROM: root\n") ;<br>
$hostreplay=fgets($fp,128) ;<br>
if (!strstr($hostreplay,"250")) {<br>
fputs($fp,"MAIL FROM: root@263.net\n") ;<br>
echo($hostreplay=fgets($fp,128)) ;<br>
if (!strstr($hostreplay,"250")) {<br>
fputs($fp,"MAIL FROM: $from_address\n") ;<br>
$hostreplay=fgets($fp,128) ;<br>
if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;<br>
};<br>
};<br>
};<br>
fputs($fp,"RCPT TO: $to_address\n") ;<br>
$hostreplay=fgets($fp,128);<br>
if (!strstr($hostreplay,"250")) {<br>
fputs($fp,"RCPT TO: $mailname\n") ;<br>
$hostreplay=fgets($fp,128) ;<br>
if (!strstr($hostreplay,"250")) echo(" can n't receive the 354 answer") ;<br>
};<br>
fputs($fp,"DATA\n") ;<br>
$hostreplay=fgets($fp,128) ;<br>
if (!strstr($hostreplay,"354")) die(" can n't receive the 250 answer ") ;<br>
$tosend="From: $from_address\n";<br>
$tosend.="To: $to_address\n";<br>
$tosend.="Subject:".str_replace("\N"," ",$subject)."\n你好,这是yukuang发给您的一封测试信!!<br>
<br>
\n.\n";<br>
fputs($fp,$tosend) ;<br>
$hostreplay=fgets($fp,128) ;<br>
if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;<br>
fputs($fp,"QUIT\n") ;<br>
fclose($fp) ;<br>
echo "发送成功";<br>
exit();<br>
//if($ck_name!='root') die("
Copy after login

bye bye ");

};

?>






























cn-bbs web meil

from


value="">
to
value="">
subject

c

o

n

t

e

n

t


















该程序在局域网内调试通过,我的IP是202.110.200.242,供大家测试
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template