0

Hello!

Currently I have a form where the user can submit emails in a comma separated format to the $row in database $contacts. How can I set this up correctly so the user can email their contacts? As of right now the script emails everybody but just not in the correct email format. Thank You!

<?php

$formMessage = "";
$senderName = "";
$senderEmail = "";
$senderMessage = "";
if (isset($_POST['cusername']))
{

 
    // Gather the posted form variables into local PHP variables
    $senderName = $_POST['cusername'];
    $senderEmail = $_POST['cemail'];
    $senderMessage = $_POST['msg'];
    // Make sure certain vars are present or else we do not send email yet
    if (!$senderName || !$senderEmail ) {
 
         $formMessage = "The form is incomplete, please fill in all fields.";
 
    } else { // Here is the section in which the email actually gets sent

        // Run any filtering here
        $senderName = strip_tags($senderName);
        $senderName = stripslashes($senderName);
        $senderEmail = strip_tags($senderEmail);
        $senderEmail = stripslashes($senderEmail);
        $senderMessage = strip_tags($senderMessage);
        $senderMessage = stripslashes($senderMessage);
        // End Filtering
 $to = "$contacts";         

   $from = "";
        $subject = "Prospect For Property";
        // Begin Email Message Body
  $message = '<html><body>';
';

$message .= "</body></html>";
        // Set headers configurations
		 $headers = "MIME-Version: 1.0\r\n";

      
       

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        // Mail it now using PHP's mail function
        mail($to, $subject, $message, $headers);
        $formMessage = "Thanks, your message has been sent.";
        $senderName = "";
        $senderEmail = "";
        $senderMessage = "";
    } // close the else condition

} // close if (POST condition
?>

Edited by bbizzl: n/a

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by pritaeas
0

As of right now the script emails everybody but just not in the correct email format.

Please explain, what format is not correct ?

0

Please explain, what format is not correct ?

I would like to hide the recipients addresses. As the script lies now, all the recipients addresses show when emailed.

0

Use Bcc and put it in the additional header. See an example in the documentation.

That is a good example but I can't get it to fire off the emails in the bcc field. The emails come from a comma separated row in the database. Works fine when I use only the $to field. Let me know if you see anything in the script.

<?php

$formMessage = "";
$senderName = "";
$senderEmail = "";
$senderMessage = "";
if (isset($_POST['cusername']))
{

 
    // Gather the posted form variables into local PHP variables
    $senderName = $_POST['cusername'];
    $senderEmail = $_POST['cemail'];
    $senderMessage = $_POST['msg'];
    // Make sure certain vars are present or else we do not send email yet
    if (!$senderName || !$senderEmail ) {
 
         $formMessage = "The form is incomplete, please fill in all fields.";
 
    } else { // Here is the section in which the email actually gets sent

        // Run any filtering here
        $senderName = strip_tags($senderName);
        $senderName = stripslashes($senderName);
        $senderEmail = strip_tags($senderEmail);
        $senderEmail = stripslashes($senderEmail);
        $senderMessage = strip_tags($senderMessage);
        $senderMessage = stripslashes($senderMessage);
        // End Filtering
 $to  = '' . ', ';

   $from = "";
        $subject = "Prospect For Property";
      $message = '<html><body>';
$message .= '
';

$message .= "</body></html>";
        // Set headers configurations
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'To:  Bbizzl<bbizzl@bbizzl.com>' . "\r\n";
$headers .= 'From:no-reply <no-reply@no-reply.com>' . "\r\n";
$headers .= 'Cc:' . "\r\n";
$headers .= 'Bcc: $contacts' . "\r\n";
        // Mail it now using PHP's mail function
        mail($to, $subject, $message, $headers);
        $formMessage = "Thanks, your message has been sent.";
        $senderName = "";
        $senderEmail = "";
        $senderMessage = "";
    } // close the else condition

} // close if (POST condition
?>
0

Use Bcc and put it in the additional header. See an example in the documentation.

In the context of correspondence, blind carbon copy (abbreviated Bcc) refers to the practice of sending a message to multiple recipients in such a way that conceals the fact that there may be additional addressees from the complete list of recipients. This concept originally applied to paper correspondence and now also applies to email.
Source

Edited by Stefano Mtangoo: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.