Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

BCC in mail script

the mail() function

Moderators: macek, egami, gesf

BCC in mail script

Postby moossy12 » Fri Jan 31, 2014 6:21 am

Hi, I have this mailscript. I use to send a file to an emailadres. Now i have to send the same file to more than one person in BCC. Everything works except for the BCC part.
This is my script:

<?php
// Email address to which you want to send email
$to = "roelg@mac.com";
$subject = $_POST["fieldSubject"];
$message = nl2br($_POST["fieldDescription"]);

/*********Creating Uniqid Session*******/

$txtSid = md5(uniqid(time()));

$headers = "";
$headers .= "From: ".$_POST["fieldFormName"]."<".$_POST["fieldFormEmail"].">\nReply-To: ".$_POST["fieldFormEmail"]."";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$txtSid."\"\n\n";
$headers .= "This is a multi-part message in MIME format.\n";

$headers .= "--".$txtSid."\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
$headers .= $message."\n\n";


/***********Email Attachment************/
if($_FILES["attachment"]["name"] != "")
{
$txtFilesName = $_FILES["attachment"]["name"];
$txtContent = chunk_split(base64_encode(file_get_contents($_FILES["attachment"]["tmp_name"])));
$headers .= "--".$txtSid."\n";
$headers .= "Content-Type: application/octet-stream; name=\"".$txtFilesName."\"\n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment; filename=\"".$txtFilesName."\"\n\n";
$headers .= $txtContent."\n\n";

}

// @ is for skiping Errors //
$flgSend = @mail($to,$subject,null,$headers);

if($flgSend)
{
echo "Email Sent SuccessFully.";
}
else
{
echo "Error in Sending Email.";
}
?>

Thx
Roel
moossy12
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Jan 31, 2014 6:14 am

Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron