
Funkcja testująca zawartość pól formularza:
   function test_content_mail($value) {
       if(eregi(‘Content-Transfer’, $value) || eregi(‘Content-Type’, $value)) Â
           $value = ‘error’;
       if(eregi(‘Subject:’, $value) || eregi(‘bcc:’, $value)) Â
           $value = ‘error’;
       if(eregi(‘MIME-Version’, $value))
           $value = ‘error’;      Â
      Â
       return $value;
   }
Funkcja generujÄ…ca treść maila: (pola do wysłąnia zaczynaja siÄ™ od prefiksu ‘f_’)
   function mail_tresc($data) {
        foreach($data as $key => $value) {
            if(preg_match(„/^f_/”, $key)) {
                $error = test_content_mail($value);
                if($error==’error’) {
                    $content=’error’;
                    break;
                }
                $content .= substr($key, 2) . ‘: ‘ . $value . „\n”;
            }
        }
        return $content;
   }
   $content = mail_tresc($_REQUEST);
   if($content==’error’) {
       echo ‘Error… Wprowadzono niedozowlone tresci.’;
       exit();
   }
   $to = ‘kody@kody.wig.pl’;
   $from = ‘test@kody.wig.pl’;
   $subject = ‘Temat’;
Dodatkowe nagłówki maila:
   $headers = „From: $from\r\n”;
   $headers .= „Subject: Temat\r\n”;
   $headers .= „MIME-Version: 1.0\r\n”;     Â
   $headers .= „Content-Type: text/plain; charset=ISO-8859-2; format=flowed\r\n”;
   $headers .= „Content-Transfer-Encoding: 7bit”;
   $body    = ‘Treść’.”\n\n”.$content.”\r\n”;
   $mail_status = mail($to, $subject, $body, $headers);   $url = $_SERVER['HTTP_REFERER'];
   $pos = strpos($url, ‘&wyslano’);Zabezpiszenie przed doklejaniem w nieskoÅ„czoność fo referera zmiennej ‘wyslano’
   if($pos) {
       $url = substr($url, 0, strpos($url, ‘&wyslano’));
   }
   header(„Location: „.$url.’&wyslano=1′);
   exit();
Strona zawiera sposoby oraz kody źródłowe pokazujące rozwiazanie napotkanych problemów