0

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

2
Contributors
5
Replies
37
Views
1 Year
Discussion Span
Last Post by Coderunner
0

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.

0

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

Regards

0

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.

0

@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

0

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

Edited by Coderunner

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.