在php 中使用mail函数
2015-10-11 20:06
676 查看
注:php环境配置完整,参考 http://www.cnblogs.com/homezzm/archive/2012/08/01/2618062.html
1.本地windows需安装SMTP服务器,建议使用Free SMTP Server,链接——http://www.softstack.com/freesmtp.html
2.安装完成后 查看自己的php配置文件,即php.in中是否有如下配置:
SMTP = localhost
; http://php.net/smtp-port smtp_port = 25
3.接下来演示代码,创建一个html表单输入,一个php文件进行处理,本地smtp服务器充当邮局向外发送。
(1)feedback.html
(2)processfeedback.php
1.本地windows需安装SMTP服务器,建议使用Free SMTP Server,链接——http://www.softstack.com/freesmtp.html
2.安装完成后 查看自己的php配置文件,即php.in中是否有如下配置:
SMTP = localhost
; http://php.net/smtp-port smtp_port = 25
3.接下来演示代码,创建一个html表单输入,一个php文件进行处理,本地smtp服务器充当邮局向外发送。
(1)feedback.html
<form action="processfeedback.php" method="post" xmlns="http://www.w3.org/1999/html"> <br>Name</br> <input type="text" name="name" size="6"></p> <p>email</br> <input typr="text" name="email" size="17" maxsize="40"></p> <p>Your Feedback</br> <input type="text" style="height:40px ;width:125px" name="feedback"></p> <p><input type="submit" value="submit"></p> </form>
(2)processfeedback.php
<?php date_default_timezone_set("PRC"); $name=trim($_POST['name']); $email=trim($_POST['email']); $feedback=trim($_POST['feedback']); $toaddress="xxxxxxxxx@qq.com";//此处是你要送达人的邮件地址 $emailcontent="customer name:".$name."feedback:".$feedback; $subject="$feedback from wed site"; $fromaddress="From:xxxxx@localhost.com";//发件人即自己的邮件地址,随便写一个即可 mail($toaddress,$subject,$emailcontent,$fromaddress);//第一个参数是收件人地址,第二个是标题,第三个是内容,第四个是发件人地址 ?> <html xmlns="http://www.w3.org/1999/html"> <head> <title>Bob's Auto Parts-Feedback Submitted</title> </head> <body> <h1>Feed Back Submitted</h1> <p>Your Feed back have been sent.</p> <?php echo nl2br($emailcontent); ?> </body> </html>
相关文章推荐
- phpStudy如何修改端口及WWW目录
- Rehl7 设置ntp服务,同步指定服务器时间。Ntp改为chrony
- laravel routes除了默认路由,其他的都无效 解决方案
- PHP选择性备份MySQL数据库完整函数
- 对web应用中单一入口模式的理解及php实现
- 批量下载FTP上的文件
- PHP备份MySQL数据库
- PHP打印调用堆栈信息,用于程序调试
- php中使用end方法报错
- ThinkPHP控制器分级
- Laravel 报错 :Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING)
- 【PHP】找几个例子就能快速复习PHP基础知识
- php-判断一个文件是否存在,便于删除等操作
- php mkdir函数
- php实现Mysql简易操作类
- 【PHP】PHP MySQL问题 phpinfo() 没有显示MySQL模块
- ThinkPHP 3.2.3 实现搜索分页
- JTextpane 加入的行号
- php正则提取img所有属性值
- PHP第一季视频教程.李炎恢.学习笔记(四)(第2章 基本语法(3))