PHP生成图片E-mail地址

mail.php代码

<?
/*
MailX Managment System 0.8  Beta
*/
header("Content-type:image/png");
$mailaddress=$_GET['mailname'];
$mailaddresslen=strlen($mailaddress);
$mailaddressimages=imagecreate($mailaddresslen*10,25);
$lenadd=$mailaddresslen;
$fontsize="4";
$center=(imagesx($mailaddressimages)-8.3*strlen($mailaddress))/2;
$mailimagesbackground=ImageColorAllocate($mailaddressimages,255,255,255);
$mailimagesfacecolor=ImageColorAllocate($mailaddressimages,0,0,0);
ImageString($mailaddressimages,$fontsize,$center,5,$mailaddress,$mailimagesfacecolor);
Imagepng($mailaddressimages);
ImageDestroy($mailaddressimages);
?>

255,255,255 生成图片的背景颜色(RGB哦)
$fontsize=”4″;字体大小
( $mailaddresslen*10,25); $mailaddresslen*10表示:生成图片宽:Email地址字符个数*10,25表示高

以上代码保存为mail.php 然后访问mail.php?mailname=you@domain.com,就可以输出mailname=后面的邮件地址了.
当然,如果你嫌麻烦,可以用一个表单来代替.如下:

index.html代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01  Transitional//EN"  "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html  xmlns="http://www.w3.org/1999/xhtml"  />
<head>
<title>Welcome to  domain.com</title>
<meta http-equiv="Content-Language" content="en"  />
</head>
<body>
<form action="mail.php"  mothod="post">
You email:<input name="mailname" type="text"  value="Webmaster@domain.com" /><br /><input type="submit" value="确定"  />
</form>
</body>
</html>
affiliate_link
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “PHP生成图片E-mail地址”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>