mrwhitee Posted November 19, 2007 Share Posted November 19, 2007 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. Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 19, 2007 Share Posted November 19, 2007 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. Quote Link to comment Share on other sites More sharing options...
mrwhitee Posted November 19, 2007 Author Share Posted November 19, 2007 Thanks, I will check it out tonight. Quote Link to comment Share on other sites More sharing options...
mrwhitee Posted November 20, 2007 Author Share Posted November 20, 2007 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,); ?> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 20, 2007 Share Posted November 20, 2007 if you wanting to send out one email at a time per email address; so it looks like you are sending each person a personal email; you can put all the email address in an array and do a for loop to process mail() variable for each key. i think this will accomplish what you want to do. Quote Link to comment Share on other sites More sharing options...
mrwhitee Posted November 20, 2007 Author Share Posted November 20, 2007 are you talking about doing that with the first script with the php mail function? Seems like that would work. I wonder if that would slow it down though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.