[Techtalk] PHP question

Chantal Rosmuller chantal at antenna.nl
Tue Nov 28 12:01:14 UTC 2006


Hi everyone,

I hope I can also ask a PHP question here, I also sent it to the PHP general 
mailing list but up to now I haven't gotten the answer I was looking for. 

I'm working on a mailform and it's kind of working but I still have 2 
problems:

1) I can't get the From header right, when I receive the test mail the sender 
is apache
2) The BCC headers (there's more then one) are not stripped.

Here's my script:

        /* haal de gegevens op */
        $to=$_POST['to'];
        $bcc=$_POST['bcc'];
        $subject=$_POST['subject'];
        $bericht=$_POST['bericht'];

        /* maak van de bcctjes een array en bouw hier de bcc headers van */
        $bcc_array = explode (",", $bcc);
        for ($n = 0; $n < count($bcc_array); $n++) 
                {
                $bcclist=each($bcc_array);
                $bccheaders = $bccheaders . "bcc:" . $bcclist[value] . "\r\n";
                }

        /*Nu gaan we een aantal headers bekijken en toevoegen.*/
        $headers .= "To: $to \r\n";
        /* from adres */
        $headers .= "From: $mainmail \r\n";
        /*Deze twee headers zorgen ervoor dat je een bericht met HTML kan 
toevoegen*/
        $headers  .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
        /*Deze header zorgt ervoor dat als er een fout is ontstaan bij het 
versturen 
van een mailtje, dat je kan aangeven naar welke e-mailadres de fout/error 
gestuurd wordt.*/
        $headers .= "Return-Path: $mainmail\r\n";
        /*Deze header zorgt ervoor dat als ontvangers een reply terug willen 
sturen 
naar jou, dat hun reactie naar dit adres wordt terug gestuurd.*/
        $headers .= "Reply-To: $mainmail\r\n";

        $headers .= "X-Mailer: PHP" . phpversion() ."\r\n";
        $headers = $headers . $bccheaders;
        
        mail($to, $subject, $bericht, $headers);
        echo "Mail met onderwerp $subject is verstuurd naar $bcc en 
$mainmail";

Thanks, regards Chantal


More information about the Techtalk mailing list