Skip to content
Advertisement

send different email to different recipient php mail [closed]

for($f=0; $f<count($person); $f++){

        $messageUser = "<div style='display: block; width: 520px; background-color: #edeeef; padding: 10px;'>
                        <p>Please confirm the payment voucher for<br>
                        <br>Request by: ".$usercreated."
                        <br>Voucher Name: ".$pv_name."
                        <br><br>Your pin no: <strong>".$pin[$f]."</strong>
                            <button>Confirm Account</button>
                        </a>
                        </div>
                        ";

        $headers .= "Reply-To: Nothing <admin@nothing.com>rn"; 
        $headers .= "Return-Path: Nothing <admin@nothing.com>rn"; 
        $headers .= "From: Nothing <admin@nothing.com>rn";  
        $headers .= "Bcc: Nothing <sales@nothing.com>rn"; 
        $headers .= "Organization: Nothingrn";
        $headers .= "MIME-Version: 1.0rn";
        //    $headers .= "Content-type: text/plain; charset=iso-8859-1rn";
        $headers .= "Content-type: text/htmlrn";
        $headers .= "X-Priority: 3rn";
        $headers .= "X-Mailer: PHP". phpversion() ."rn" ;
        $from = "admin@nothing.com";

        $retvaladmin2 = mail($person[$f],$subject,$messageUser,$headers, "-f" . $from);
            if($retvaladmin2){
                $statusemail = 'success';
            }
echo $person[$f];
echo "<br>";
echo $statusemail;
echo "<br>";

}

i want to send verification code which is $pin[$f] for different recipients and each recipient will have unique pin. I make it loop for sending the email. the first recipient received the email but the second recepient didnt. it shows the error of 554 Transaction failed: Duplicate header ‘From’

Advertisement

Answer

You need to clear out $headers between loop iterations.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement