今天初学PHP,尝试用PHP发送邮件简要显示客户表单内容,为此安装了SMTP服务器 Easy SMTP Server ,发送邮件成功,另外一个重要发现是邮件发送者可以在PHP中任意指定,这点让我挺意外。
编写mailtest.html
<span style="font-size:18px;"><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>伪造邮件攻击测试</title>
</head>
<body>
<form action="mailtest.php" method="post">
<label for="email">Email Address:</label>
<input type="text" id="email" name="email"><br>
<input type="submit" value="提交" name="submit">
</form>
</body>
</html>
</span>
服务器mailtest.php
<span style="font-size:18px;"><?php
$email = $_POST['email'];
$to = '739326808@qq.com';
$subject = "Test";
$msg="This is a fake test mail!";
mail($to, $subject, $msg, 'From:' . $email);
?></span>
直接编写fakemail.php
<span style="font-size:14px;"><?php
$email = "lxyang@seu.edu.cn";
$to = '739326808@qq.com';
$subject = "Test";
$msg="This is a fake test mail!";
mail($to, $subject, $msg, 'From:' . $email);
?></span>
也能发送成功 ????
就上面mailtest.html而言,若输入的是qqAdmin@qq.com 会出现
Warning: mail(): SMTP server response: 550 Invalid recipient: 739326808@qq.com in E:\Workspaces\PHP\mailtest.php on line 6 | ||||
---|---|---|---|---|
Call Stack |
# | Time | Memory | Function | Location |
---|---|---|---|---|
1 | 0.0000 | 241384 | {main}( ) | ..\mailtest.php:0 |
2 | 0.0000 | 242136 | mail ( ) | ..\mailtest.php:6 |
查看了一下SMTP错误码
http://blog.youkuaiyun.com/chenfei_5201213/article/details/10138969
无效的收信者账号,推测有可能是SMTP服务器的问题。。。没配置,安装直接使用的