PHP mail详细示例
From:http://php.net/manual/zh/function.mail.php
Example #1 Sending mail.
Using mail() to send a simple email:
<?php
// The message
$message = "Line 1\nLine 2\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('caffinated@example.com', 'My Subject', $message);
?>
Example #2 Sending mail with extra headers.
The addition of basic headers, telling the MUA
the From and Reply-To addresses:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Example #3 Sending mail with an additional command line parameter.
The additional_parameters parameter
can be used to pass an additional parameter to the program configured
to use when sending mail using the sendmail_path.
<?php
mail('nobody@example.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');
?>
Example #4 Sending HTML email
It is also possible to send HTML email with mail().
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
PHP mail详细示例的更多相关文章
- 【极力分享】[C#/.NET]Entity Framework(EF) Code First 多对多关系的实体增,删,改,查操作全程详细示例【转载自https://segmentfault.com/a/1190000004152660】
[C#/.NET]Entity Framework(EF) Code First 多对多关系的实体增,删,改,查操作全程详细示例 本文我们来学习一下在Entity Framework中使用Cont ...
- ZjDroid工具介绍及脱壳详细示例
前提条件: 1.Root手机一部 2.需要通过Xposed installer(http://dl.xposed.info/latest.apk)安装Xposed Framework; 一.ZjDro ...
- Jedis API 详细示例
Jedis API 详细示例 https://www.jianshu.com/p/125357ee7651
- asp.net core系列 39 Razor 介绍与详细示例
原文:asp.net core系列 39 Razor 介绍与详细示例 一. Razor介绍 在使用ASP.NET Core Web开发时, ASP.NET Core MVC 提供了一个新特性Razor ...
- SpringMVC详细示例
一.SpringMVC基础入门,创建一个HelloWorld程序 0.框架结构 1.首先,导入SpringMVC需要的jar包. 2.添加Web.xml配置文件中关于springmvc的配置 < ...
- asp.net core系列 40 Web 应用MVC 介绍与详细示例
一. MVC介绍 MVC架构模式有助于实现关注点分离.视图和控制器均依赖于模型. 但是,模型既不依赖于视图,也不依赖于控制器. 这是分离的一个关键优势. 这种分离允许模型独立于可视化展示进行构建和测试 ...
- asp.net core系列 39 Web 应用Razor 介绍与详细示例
一. Razor介绍 在使用ASP.NET Core Web开发时, ASP.NET Core MVC 提供了一个新特性Razor. 这样开发Web包括了MVC框架和Razor框架.对于Razor来说 ...
- 巩固一下:SpringMVC详细示例实战教程
一.SpringMVC基础入门,创建一个HelloWorld程序 1.首先,导入SpringMVC需要的jar包. 2.添加Web.xml配置文件中关于SpringMVC的配置 1 2 3 4 5 6 ...
- 史上最全最强SpringMVC详细示例实战教程
一.SpringMVC基础入门,创建一个HelloWorld程序 1.首先,导入SpringMVC需要的jar包. 2.添加Web.xml配置文件中关于SpringMVC的配置 1 2 3 4 5 6 ...
随机推荐
- Dynamic Binding & Static Binding
Reference: JavaPoint BeginnerBook What is Binding Connecting a method call to the method body is kno ...
- c语言验证哥德巴赫猜想(从4开始 一个偶数由两个质数之和)
#include <stdio.h> #include <stdlib.h> #include <math.h> int isit(int num) { int i ...
- Css实现垂直水平居中的六种方法
经常在项目中用到,今天总结了一下: 演示地址:http://codepen.io/anon/pen/xGdpOa 以下两个类为公共类,便于更好的显示效果,非核心代码 .common{ width: 6 ...
- 压位加速-poj-2443-Set Operation
题目链接: http://poj.org/problem?id=2443 题目意思: 有n个集合(n<=1000),每个集合有m个数ai(m<=10000,1=<ai<=100 ...
- 验证docker的Redis镜像也存在未授权访问漏洞
看到了这篇老外的博客:Over 30% of Official Images in Docker Hub Contain High Priority Security Vulnerabilities于 ...
- .net学习体会
莫名其妙学了IT,在课堂上学了C,C++,自学了C#,也做了一些网站项目,学习过程,写了厚厚的几本笔记本,却没写博文的习惯,前几天,有同学问学习.net的建议.其实我懂的也不多,也给了一些个人见解,主 ...
- .NET 4.0 兼容 .NET 2.0 的方法
使用.net开发桌面应用,广大亲门最头疼的莫过于客户端部署的问题.基于.net 2.0 的winfrom程序因为 Framework 的分发包大小为20M左右还好解决,不幸的是如果项目中使用了Wcf, ...
- 通过maven创建自己的archetype
最近项目组做好一套框架,为了推广需要创建一些空白项目给项目组使用,因为所有的空白项目里面的配置基本上都是一样的,为了减少重复工作,想通过maven创建一个自己的archetype,于是在网上大致搜了一 ...
- bug调试大全
http://www.jianshu.com/p/9fc9fd89bfee http://www.cocoachina.com/ios/20150929/13598.html
- css 文本域textarea显示成label标签
<html> <head> <title>textarea显示为label</title> <style type="text/ ...