今天又写没文章更新,发一下以前的老文吧。
准备一个邮箱 这里以163邮箱为例子 开启POP3/SMTP/IMAP
服务器地址:
POP3服务器: pop.163.com
SMTP服务器: smtp.163.com
IMAP服务器: imap.163.com
开启之后163会给你一个用于其他客户端软件登录的密码 这里例如 xxx123456
用Foxmail 客户端测试能否正确使用
下载软件https://www.apachefriends.org/index.html
xamppinstaller.exe 这个是一个套间件,支持很多环境,主要有sendmail这个插件
环境安装在服务器上 这里是server2008
配置文件 php.ini 文件
C:\xampp\php\php.ini
1065行修改 SMTP=smtp.163.com
1071行修改 sendmail_from [email protected]
C:\xampp\sendmail\sendmail.ini
14 行 smtp_server=smtp.163.com
46行[email protected]
47行 auth_password=xxx123456
60行 force_sender= [email protected]
C:\xampp\htdocs目录下新建源码
<?php
if (isset($_REQUEST['fakename']))
{
$sendto = $_REQUEST['sendto'];
$fakename = $_REQUEST['fakename'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
try{
if(mail( $sendto, $subject,$message, "From: $fakename" )){
echo "success";
}else{
echo "error";
}
}catch (Exception $e) {
print $e->getMessage();
exit();
}
}
else
{
echo "
<form method='post'>
Send to: <input name='sendto' type='text' /> <br />
Fake name: <input name='fakename' type='text' /> <br />
Subject: <input name='subject' type='text' /> <br />
Message: <br />
<textarea name='message' rows='15' cols='40'></textarea> <br />
<input type='submit' />
</form>";
}
?>
配置完成后重启一下apache
进行测试
QQ邮箱做了防御会显示代发。
测试tom邮箱 这个邮箱系统是没做防御的看效果
发送邮件出错的情况
php.ini 配置失败
sendmail.ini 配置失败 错误文件情况error.log