Jump to content

cant get bcc to work with mail script


mrwhitee

Recommended Posts

I am very new to programming but have made a mail script that I need to mail people on my subscription list.I thought I had it almost ready and realized you could see all the emails in the to: field. This will be very bad. I have tried several ways and cant seem to come up with a solution.

 

<?php

$username = "myusername";
$password = "mypassword";
$hostname = "localhost";	
$dbh = mysql_connect($hostname, $username, $password) 
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
$selected = mysql_select_db("database",$dbh) 
or die("Could not select database");
$result = mysql_query("SELECT  email FROM list_subscript");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo $row{'email'}.",<br>";


$sub .= $row['email'].",";
} 

$sub = rtrim($sub,",");
mysql_close($dbh);


$to = "$sub";
echo $to;
echo $subject;
echo $From;
if(isset($_POST["txtContent"])) 
{
$sContent=stripslashes($_POST['txtContent']); /*** remove (/) slashes ***/		
echo $sContent;
}
mail("$to","$subject","$sContent",
"From: <$From>\r\n" .
"MIME-Version: 1.0\r\n" .
"CC: <>\r\n" .
"Bcc: <$to>\r\n" .
"Content-type: text/html; charset=iso-8859-1" .
"X-my mailer: 1.0")

?> 

 

???

 

Hopefully there is a way to make this work.

Link to comment
Share on other sites

you may want to try imap_mail()

This function allows sending of emails with correct handling of Cc and Bcc receivers. Returns TRUE on success or FALSE on failure..

The parameters to, cc and bcc are all strings and are all parsed as rfc822 address lists.

The receivers specified in bcc will get the mail, but are excluded from the headers.

 

 

Link to comment
Share on other sites

Cant seem to get the imap function to work at all.

I tried several variatons of this

<?php

$to = "sales@somewhere.com";
$subject = "this is the subject";
$message = "this is the darn message that you will prolly never get";
$rpath = "sales@nowhere.com";
$additional_headers = "these are headers";
imap_mail ($to, $subject, $message,);

?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.