Login
网站首页 > 文章中心 > 其它

php电子邮件发送bcc_电子邮件怎么发送文件

作者:小编 更新时间:2023-10-01 16:42:00 浏览量:452人看过

电子邮件中的CC和BCC分别代表什么?

CC 英文全称是 Carbon Copy(抄送)

BCC英文全称是 Blind Carbon Copy(暗抄送).

两者的区别在于在BCC栏中的收件人可以看到所有的收件人名(TO,CC,BCC),而在TO 和CC栏中的收件人看不到BBC的收件人名

扩展资料

安全知识

电子邮件的安全问题包含两个方面,一个是邮件可能给系统带来的不安全因素,二是邮件内容本身的隐私性.

① 浏览器的安全设置.

虽然大多数Cookie对于系统来说是安全的,但在"隐私"选项卡中对它加以设置可以适当保护自己的隐私.如果担心信件内容的泄露,可以在"内容"选项卡中进行证书的设置等.

由于软件中自动处理功能的日益增加,我们会越来越多地看到由于意外地选择了错误收件人而造成的安全事件了.微软Outlook中的"可怕的自动填写功能" 就是一个很明显的例子,在使用下拉式清单的时候很容易不小心选择临近实际收件人的收件人.在讨论类似商业机密之类敏感信息的时候,这样的操作很容易导致各种安全事件的出现.

从安全角度来说,将电子邮件地址与没有必要知道的人分享,是一个坏做法.在未经允许的情况下,将电子邮件地址与陌生人分享也是不礼貌的.在发送电子邮件给多个人的时候,可以选择收件人(TO)或者抄送(CC)的方式,这样的情况下,所有收件人可以分享所有的电子邮件地址.如果没有明确确认电子邮件地址应该被所有收件人分享的时候,应该使用密送(BCC)的设置.这样的话,收件人不会知道还有其它接收者的存在.

如果在公共场所收发信件,信件内容的隐私性就变得至关重要.可以通过"Internet 选项"的"常规"选项卡删除文件(包括所有脱机内容)、清除历史记录以及删除Cookie.另外,还可以到"内容"选项卡的"个人信息"栏进行自动完成设置,清除表单以及密码等.

安全因素

安全考量包括传输安全、储存安全、发送者身份确认、接收者已收到确认、拒绝服务攻击等.有两种标准:PGP和S/MIME.

参考资料:百度百科-电子邮件

求php 发送邮件的代码?

php

class Email {

//---设置全局变量

var $mailTo = ""; // 收件人

var $mailCC = ""; // 抄送

var $mailBCC = ""; // 秘密抄送

var $mailFrom = ""; // 发件人

var $mailSubject = ""; // 主题

var $mailText = ""; // 文本格式的信件主体

var $mailHTML = ""; // html格式的信件主体

var $mailAttachments = ""; // 附件

/* 函数setTo($inAddress) :用于处理邮件的地址 参数 $inAddress

为包涵一个或多个字串,email地址变量,使用逗号来分割多个邮件地址

默认返回值为true

**********************************************************/

function setTo($inAddress){

//--用explode()函数根据","对邮件地址进行分割

$addressArray = explode( ",",$inAddress);

//--通过循环对邮件地址的合法性进行检查

for($i=0;$icount($addressArray);$i◆◆){ if($this-checkEmail($addressArray[$i])==false) return false; }

//--所有合法的email地址存入数组中

$this-mailTo = implode($addressArray, ",");

return true; }

/**************************************************

函数 setCC($inAddress) 设置抄送人邮件地址

参数 $inAddress 为包涵一个或多个邮件地址的字串,email地址变量,

使用逗号来分割多个邮件地址 默认返回值为true

**************************************************************/

function setCC($inAddress){

$this-mailCC = implode($addressArray, ",");

/***************************************************

函数setBCC($inAddress) 设置秘密抄送地址 参数 $inAddress 为包涵一个或多

个邮件地址的字串,email地址变量,使用逗号来分割多个邮件地址 默认返回值为

true

******************************************/

function setBCC($inAddress){

for($i=0;$icount($addressArray);$i◆◆)

{ if($this-checkEmail($addressArray[$i])==false)

return false;

}

$this-mailBCC = implode($addressArray, ",");

return true;

/*****************************************************************

函数setFrom($inAddress):设置发件人地址 参数 $inAddress 为包涵邮件

地址的字串默认返回值为true

***************************************/

function setFrom($inAddress){

if($this-checkEmail($inAddress)){

$this-mailFrom = $inAddress;

} return false; }

/**********************

函数 setSubject($inSubject) 用于设置邮件主题参数$inSubject为字串,

默认返回的是true

*******************************************/

function setSubject($inSubject){

if(strlen(trim($inSubject)) 0){

$this-mailSubject = ereg_replace( "n", "",$inSubject);

return false; }

/****************************************************

函数setText($inText) 设置文本格式的邮件主体参数 $inText 为文本内容默

认返回值为true

****************************************/

function setText($inText){

if(strlen(trim($inText)) 0){

$this-mailText = $inText;

/**********************************

函数setHTML($inHTML) 设置html格式的邮件主体参数$inHTML为html格式,

************************************/

function setHTML($inHTML){

if(strlen(trim($inHTML)) 0){

$this-mailHTML = $inHTML;

函数 setAttachments($inAttachments) 设置邮件的附件 参数$inAttachments

为一个包涵目录的字串,也可以包涵多个文件用逗号进行分割 默认返回值为true

function setAttachments($inAttachments){

if(strlen(trim($inAttachments)) 0){

$this-mailAttachments = $inAttachments;

/*********************************

函数 checkEmail($inAddress) :这个函数我们前面已经调用过了,主要就是

用于检查email地址的合法性

*****************************************/

function checkEmail($inAddress){

/*************************************************

函数loadTemplate($inFileLocation,$inHash,$inFormat) 读取临时文件并且

替换无用的信息参数$inFileLocation用于定位文件的目录

$inHash 由于存储临时的值 $inFormat 由于放置邮件主体

***********************************************************/

function loadTemplate($inFileLocation,$inHash,$inFormat){

/* 比如邮件内有如下内容: Dear ~!UserName~,

Your address is ~!UserAddress~ */

//--其中"~!"为起始标志"~"为结束标志

$templateDelim = "~";

$templateNameStart = "!";

//--找出这些地方并把他们替换掉

$templateLineOut = ""; //--打开临时文件

if($templateFile = fopen($inFileLocation, "r")){

while(!feof($templateFile)){

$templateLine = fgets($templateFile,1000);

$templateLineArray = explode($templateDelim,$templateLine);

for( $i=0; $icount($templateLineArray);$i◆◆){

//--寻找起始位置

if(strcspn($templateLineArray[$i],$templateNameStart)==0){

//--替换相应的值

$hashName = substr($templateLineArray[$i],1);

$templateLineArray[$i] = ereg_replace($hashName,(string)$inHash[$hashName],$hashName);

//--输出字符数组并叠加

$templateLineOut .= implode($templateLineArray, "");

} //--关闭文件fclose($templateFile);

//--设置主体格式(文本或html)

if( strtoupper($inFormat)== "TEXT" )

return($this-setText($templateLineOut));

else if( strtoupper($inFormat)== "HTML" )

return($this-setHTML($templateLineOut));

} return false;

/*****************************************

函数 getRandomBoundary($offset) 返回一个随机的边界值

function getRandomBoundary($offset = 0){

//--随机数生成

srand(time()◆$offset);

/********************************************

函数: getContentType($inFileName)用于判断附件的类型

**********************************************/

function getContentType($inFileName){

//--去除路径

$inFileName = basename($inFileName);

//--去除没有扩展名的文件

if(strrchr($inFileName, ".") == false){

return "application/octet-stream";

//--提区扩展名并进行判断

$extension = strrchr($inFileName, ".");

switch($extension){

case ".gif": return "image/gif";

case ".gz": return "application/x-gzip";

case ".htm": return "text/html";

case ".html": return "text/html";

case ".jpg": return "image/jpeg";

case ".tar": return "application/x-tar";

case ".txt": return "text/plain";

case ".zip": return "application/zip";

default: return "application/octet-stream";

/**********************************************

函数formatTextHeader把文本内容加上text的文件头

*****************************************************/

function formatTextHeader(){ $outTextHeader = "";

$outTextHeader .= "Content-Type: text/plain;

charset=us-asciin";

$outTextHeader .= $this-mailText. "n";

return $outTextHeader;

} /************************************************

函数formatHTMLHeader()把邮件主体内容加上html的文件头

function formatHTMLHeader(){

$outHTMLHeader = "";

$outHTMLHeader .= "Content-Type: text/html;

$outHTMLHeader .= $this-mailHTML. "n";

return $outHTMLHeader;

函数 formatAttachmentHeader($inFileLocation) 把邮件中的附件标识出来

********************************/

function formatAttachmentHeader($inFileLocation){

$outAttachmentHeader = "";

//--用上面的函数getContentType($inFileLocation)得出附件类型

$contentType = $this-getContentType($inFileLocation);

if(ereg( "text",$contentType)){

$outAttachmentHeader .= "Content-Type: ".$contentType. ";n";

$outAttachmentHeader .= ' name="'.basename($inFileLocation). '"'. "n";

$outAttachmentHeader .= "Content-Disposition: attachment;n";

$outAttachmentHeader .= ' filename="'.basename($inFileLocation). '"'. "nn";

$textFile = fopen($inFileLocation, "r");

while(!feof($textFile)){

$outAttachmentHeader .= fgets($textFile,1000);

//--关闭文件 fclose($textFile);

$outAttachmentHeader .= "n";

else{ $outAttachmentHeader .= "Content-Type: ".$contentType. ";n";

//--调用外部命令uuencode进行编码

exec( "uuencode -m $inFileLocation nothing_out",$returnArray);

for ($i = 1; $i(count($returnArray)); $i◆◆){

$outAttachmentHeader .= $returnArray[$i]. "n";

} return $outAttachmentHeader;

/******************************

函数 send()用于发送邮件,发送成功返回值为true

function send(){

//--设置邮件头为空

$mailHeader = "";

//--添加抄送人

if($this-mailCC != "")

$mailHeader .= "CC: ".$this-mailCC. "n";

//--添加秘密抄送人

if($this-mailBCC != "")

$mailHeader .= "BCC: ".$this-mailBCC. "n";

//--添加发件人

if($this-mailFrom != "")

$mailHeader .= "FROM: ".$this-mailFrom. "n";

//---------------------------邮件格式------------------------------

//--文本格式

if($this-mailText != "" $this-mailHTML == "" $this-mailAttachments == ""){

return mail($this-mailTo,$this-mailSubject,$this-mailText,$mailHeader);

//--html或text格式

else if($this-mailText != "" $this-mailHTML != "" $this-mailAttachments == ""){

$bodyBoundary = $this-getRandomBoundary();

$textHeader = $this-formatTextHeader();

$htmlHeader = $this-formatHTMLHeader();

//--设置 MIME-版本

$mailHeader .= "MIME-Version: 1.0n";

$mailHeader .= "Content-Type: multipart/alternative;n";

$mailHeader .= ' boundary="'.$bodyBoundary. '"';

$mailHeader .= "nnn";

//--添加邮件主体和边界

$mailHeader .= "--".$bodyBoundary. "n";

$mailHeader .= $textHeader;

//--添加html标签

$mailHeader .= $htmlHeader;

$mailHeader .= "n--".$bodyBoundary. "--";

//--发送邮件

return mail($this-mailTo,$this-mailSubject, "",$mailHeader);

//--文本加html加附件

else if($this-mailText != "" $this-mailHTML != "" $this-mailAttachments != ""){

$attachmentBoundary = $this-getRandomBoundary();

$mailHeader .= "Content-Type: multipart/mixed;n";

$mailHeader .= ' boundary="'.$attachmentBoundary. '"'. "nn";

$mailHeader .= "This is a multi-part message in MIME format.n";

$mailHeader .= "--".$attachmentBoundary. "n";

$bodyBoundary = $this-getRandomBoundary(1);

//--获取附件值

$attachmentArray = explode( ",",$this-mailAttachments);

//--根据附件的个数进行循环

for($i=0;$icount($attachmentArray);$i◆◆){

//--分割 $mailHeader .= "n--".$attachmentBoundary. "n";

//--附件信息

$mailHeader .= $this-formatAttachmentHeader($attachmentArray[$i]);

$mailHeader .= "--".$attachmentBoundary. "--";

php怎么实现发送邮件

怎么利用php发送邮件求详细教程

PHP虽然提供了mail()函数,但并不好用,而PHPMailer是一个不错的邮件发送工具,此时此刻呢将详细介绍,需要了解的朋友可以参考下:

[php] view plain copy

$subject = "Test mail";

$message = "Hello! This is a simple email message.";

$headers = "From: $from";

$send=mail($to,$subject,$message,$headers);

if($send)

echo "Mail Sent";

else

echo "Sorry,mail sent failed!"

/span

在CSDN论坛上发现phpmailer可以方便快捷的发送邮件,以下写出详细使用教程:

以下为前台表单php代码:

body

form name="phpmailer" action="testemail.php" method="post"

input type="hidden" name="submitted" value="1"/

br/

input type="submit" value="发送"/

/form

/body

/html /span

以下为后台程序:

/**

* Simple example script using PHPMailer with exceptions enabled

* @package phpmailer

* @version $Id$

*/

ini_set("magic_quotes_runtime",0);

require('class.phpmailer.php');

try {

$mail = new PHPMailer(true); //New instance, with exceptions enabled

//$body = file_get_contents('contents.html');

//$body = preg_replace('/\\\\/','', $body); //Strip backslashes

$to = $_POST['to'];

$mail-IsSMTP(); // tell the class to use SMTP

$mail-SMTPAuth = true; // enable SMTP authentication

$mail-Host = "smtp.qq.com"; // SMTP server

$mail-Password = "000000000000"; // SMTP server password

//$mail-IsSendmail(); // tell the class to use Sendmail

$mail-FromName = "han qing";

$mail-AddAddress($to);

$mail-Body = "h1phpmailer演示/h1 这是用PHPMAILER发的第一份邮件,从QQ邮箱发到Google邮箱.";

$mail-AddAttachment("F:/myloe.jpg");

$mail-AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

//$mail-MsgHTML($body);

$mail-IsHTML(true); // send as HTML

$mail-Send();

echo 'Message has been sent.';

} catch (phpmailerException $e) {

echo $e-errorMessage();

php中邮件密抄怎么使用

增加其他收信人的时候使用bcc,密抄送.不知道你是用的什么样的发送方式,mail函数的话如下,其中写到header中,bcc后面的地址就是密抄送了.

$headers = 'MIME-Version: 1.0' . "\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电子邮件发送bcc相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章