Hello,

I have a php script which devide the emails in groups so that each group can send separately. Servers can look it as spam if the group is too big.
Now how can I add the correct email address of each person in this script below (cfr '. $ ??? .')
I hope somebody can help me with this. Please give code not just how to do it because I tried it for weeks now.
My php code so far without adding email receiver ...

    $Newletter = "subject: $subject\nmessage:\n\n$message"; 
    $Newletter = stripslashes($Newletter); 
    $Newletter = nl2br(htmlspecialchars(trim($Newletter))); 

    if($user == $_POST['user'] && $password == $_POST['password'] && $_SERVER['REQUEST_METHOD'] == 'POST' ) 
    {
        $NewletterFile = file($dateFile);
        $NewletterFileLenght = count($NewletterFile);

        $groupsCounter = 0;

        for($i = 0; $i < ($NewletterFileLenght+50); $i+=50) 
        {
            $group = null;
            $groupsCounter++;
            for($a = $i; $a < ($i+50); $a++) 
            {
                if($NewletterFile[$a]) 
                {
                    $group .= trim($NewletterFile[$a]).",";
                }
            }
            if($group) { $groups[] = $group; }
        }


            for( $i = 0; $i < count( $groups ); $i++ ) 
            {
                $to = $yourEmail;
                $subject = stripslashes($_POST['subject']);
                $_POST['message'] = str_replace("\n", "<br />", $_POST['message']);
                $message = nl2br(stripslashes($_POST['message'])).'<br /><br /><br /><center>You received this message because you subscribed to our newsletter.<br />
                        The email address you entered is '. $???? .'<br />
                        To unsubscribe, <a href='. $Unsubscribe .'>click here</a>.<br />';

                $headers .= 'Bcc:'."$groups[$i]". "\r\n";
                $headers .= 'From:'.utf8_decode($yourWebsiteName).' <'.$yourEmail.'>' . "\r\n";
                $headers .= "MIME-Version: 1.0\n";
                $headers .= "Content-Transfer-Encoding: 8bit\n";
                $headers .= "Content-type: text/html; charset=utf-8\n";

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

            }

Thanks in advance, you will do me a big favour.
Regards
Coderunner

But you're adding in the group as a bcc list, meaning a lot of people (everyone mentioned in the bcc) gets the same email body.
You can't personalise that to include the email of each bcc person.
You would need to send one email to each person, no bcc, and include $youremail in place of the $??? to fix your problem.

Okay thanks for your reply. Is it possible to send me the code of what you say. I'm a php beginner :-(

Regards

You just need to loop through your $group, getting each email address and sending one email per address. So alter line 27 to run through all individual items in $groups.

@hericles
sorry hericles but as I said before
Is it possible to send me the code of what you say cause I don't know what you explain, my head keeps on turning now. I'm a totally php beginner :-(

Regards and respect to all the php experts

This topic may be closed or even deleted completely cause as hericles says sending bcc AND personalization every email is indeed impossible cause with bcc every email has the same contents.

Thanks for helping me hericles

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.