简体   繁体   English

我想在这个邮件功能中使用 bcc 或 cc 功能吗?

[英]i want to use bcc or cc function in this mail function?

i want to use bcc or cc function in this mail function?我想在这个邮件功能中使用 bcc 或 cc 功能吗?

Here My Mail Function这里是我的邮件功能

 <?php
//SENDS EMAIL THAT TELLS THE USER TO ACTIVATE THE ACCOUNT
$activation = 'activation.php?key='.$key;
$your_email = 'non-reply@mydomain.pk'; //CHANGE TO YOUR SETTINGS
$domain = $_SERVER["HTTP_HOST"]; //YOUR DOMAIN AND EXTENSION
$to  = $email;
$subject = 'MyDomain Activate Account';
$message .='<img src="http://mydomain.com/images/securedownload.jpg"/>';
$message = 'Welcome,<br/> '.$_POST['username'].'. You must activate your account via   this       message to log in. Click the following link to do so:   http://'.$domain.'/'.$activation;
$headers = 'From: Mydomain<'.$your_email.'@'.$domain.'>\r\n'; //MODIFY TO YOUR SETTINGS
$headers .= 'Content-type: text/html\r\n';
mail($to, $subject, $message,  $headers);
?>

You should add to the to and headers part of the mail.您应该添加到邮件的 to 和 headers 部分。

For TO part对于 TO 部分

$to = "to@to.com, cc@cc.com"

For HEADERS part对于 HEADERS 部分

$headers .= "To: To Name <to@to.com>\n";
$headers .= "CC: CC Name <cc@cc.com>\n";
$headers .= "BCC: BCC Name <bcc@bcc.com>\n"; 

It is very simple, just sharing if anyone gets help from here:很简单,如果有人从这里得到帮助,就分享一下:

//......
//...Other setting goes here....

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: My Name <myemail@example.com>'. "\r\n";
//Multiple CC can be added, if we need (comma separated);
$headers .= 'Cc: myboss1@example.com, myboss2@example.com' . "\r\n";
//Multiple BCC, same as CC above;
$headers .= 'Bcc: myboss3@example.com, myboss4@example.com' . "\r\n";

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

Just add the Bcc/CC in your Code只需在您的代码中添加密件抄送/抄送

<?php
//SENDS EMAIL THAT TELLS THE USER TO ACTIVATE THE ACCOUNT
$activation = 'activation.php?key='.$key;
$your_email = 'non-reply@mydomain.pk'; //CHANGE TO YOUR SETTINGS
$domain = $_SERVER["HTTP_HOST"]; //YOUR DOMAIN AND EXTENSION
$to  = $email;
$subject = 'MyDomain Activate Account';
$message .='<img src="http://mydomain.com/images/securedownload.jpg"/>';
$message = 'Welcome,<br/> '.$_POST['username'].'. You must activate your account via   this       message to log in. Click the following link to do so:   http://'.$domain.'/'.$activation;
$headers = 'From: Mydomain<'.$your_email.'@'.$domain.'>\r\n'; //MODIFY TO YOUR SETTINGS
$headers .=  "BCC: email@domain.com;\r\n"
$headers .= 'Content-type: text/html\r\n';
mail($to, $subject, $message,  $headers);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM