Home php教程 php手册 php 发送邮件代码

php 发送邮件代码

May 25, 2016 pm 04:49 PM
php send email

本文章是利用phpmailer来实现在线发送邮件功能的源码代码.

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>--邀请好友参加</title> 
<style type="text/css"> 
<!-- 
body { 
 margin: 0px; 
 padding: 0px; 
 font-size: 12px; 
 background-color: #CFCFCF; 
} 
input { 
 line-height: 18px; 
 height: 18px; 
 border: 1px solid #CCCCCC; 
} 
img { 
 border-top-width: 0px; 
 border-right-width: 0px; 
 border-bottom-width: 0px; 
 border-left-width: 0px; 
} 
* { 
 margin: 0px; 
 padding: 0px; 
 list-style-image: none; 
 list-style-type: none; 
 background-repeat: no-repeat; 
} 
td { 
 line-height: 22px; 
 font-size: 14px; 
 font-weight: 700; 
 color: #276662; 
} 
--> 
</style> 
</head> 
<body> 
<form action="#" method="post" name="form"> 
<table border="0" align="center" cellpadding="0" cellspacing="0"> 
  <tr> 
<td width="572" height="227" valign="top" background=http://pic2.phprm.com/2014/01/21/mailfooterimg.jpg
  <tr> 
<td height="70"> </td> 
  </tr> 
  <tr> 
<td><table width="100%" border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
<td><input type="text" value="http://111cn.net/" size="60" /></td> 
<td height="40"><a href="#"><img  src="/static/imghw/default1.png"  data-src="img/copy.gif"  class="lazy"      style="max-width:90%"  style="max-width:90%" / alt="php 发送邮件代码 " ></a></td> 
  </tr> 
</table></td> 
  </tr> 
  <tr> 
<td height="28">好友姓名: 
  <input type="text" size="22" /> 
     
  邮箱地址: 
  <input type="text" size="22" />        </td> 
  </tr> 
  <tr> 
<td height="28">好友姓名: 
  <input type="text" size="22" /> 
     
  邮箱地址: 
  <input type="text" size="22" />        </td> 
  </tr> 
  <tr> 
<td height="28">好友姓名: 
  <input type="text" size="22" /> 
     
  邮箱地址: 
  <input type="text" size="22" />        </td> 
  </tr> 
  <tr> 
<td height="28" align="right"><a href="#"><img  src="/static/imghw/default1.png"  data-src="img/sendbtn.gif"  class="lazy"      style="max-width:90%"  style="max-width:90%" / alt="php 发送邮件代码 " ></a></td> 
  </tr> 
</table></td> 
  </tr> 
</table> 
</form> 
</body> 
</html>
Copy after login


发送邮件处理功能页面mail.php

<?php
require (dirname(__FILE__) . "/mail/class.phpmailer.php"); //调用 phpmailer类型,如果没有phpmailer请点击这里下载phpmailer for php5/6 下载
$array = array_unique(Get_value(&#39;mail&#39;, 1)); //去除重复的邮箱地址
$mail = new PHPMailer();
$count = 0;
$bad = 0;
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.163.com"; // smtp1.example.com;smtp2.example.comspecify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "mailangel123"; // SMTP username
$mail->Password = "*******"; // SMTP password
$mail->From = "mailangel123@163.com";
$mail->FromName = "你的好友来信";
$MailBody = &#39;内容&#39;$mail->AddReplyTo("mailangel123@163.com", "澳优");
$mail->AddAddress($tmpmail, &#39;您好!&#39;);
$mail->WordWrap = 50;
$mail->CharSet = "GB2312";
//$mail->AddAttachment("/var/tmp/file.tar.gz");
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
$mail->IsHTML(true);
$mail->Subject = "你的朋友邀请你一起合影!";
$mail->Body = $MailBody;
if (!$mail->Send()) {
    $bad++;
    $mail->ClearAddresses();
    $mail->ClearAttachments();
}
?>
Copy after login

OK就完成了哦。 

 


教程链接:

随意转载~但请保留教程地址★

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles