Frage

I am using php mail to send mail to all members in a message thread when a new reply is posted.

            include('Mail.php');
            include('Mail/mime.php');

            // Constructing the email
            $sender = "sender@sender.com";                              // Your name and email address
            //$to= "" ;                         // The Recipients name and email address
            $subject = $Sname." has posted a reply";                                            // Subject for the email

            $html = "<html><body><p> DearMember, <br>    $Sname has replied to one of your posts. </p></body></html>";  
            $crlf = "\n";
            $headers = array(
                            'From'          => $sender,
                            'Return-Path'   => $sender,
                            'Subject'       => $subject,
                            'Bcc'           => $recipients
                            );


            // Creating the Mime message
            $mime = new Mail_mime($crlf);

            // Setting the body of the email
            $mime->setTXTBody($text);
            $mime->setHTMLBody($html);

            $body = $mime->get();
            $headers = $mime->headers($headers);

            // Sending the email
            $mail =& Mail::factory('mail');
            $mail->send(null, $headers, $body);

Right now, I am addressing the recipient as "member". Is it possible to change that to individual usernames and still use the Bcc function?

War es hilfreich?

Lösung

No, you cannot. You can either send the same message to all recipients using a long Bcc list, or you can send one personalized message to each user (calling mail() separately for each one), but there is no way to send a single email which differs for each recipient.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top