Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3794000
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:51:44+00:00 2026-05-19T12:51:44+00:00

I use this code to send a email via a contact form: <?php /*

  • 0

I use this code to send a email via a contact form:

<?php

    /* Geben Sie hier Ihre E-Mail Adresse zwischen den beiden " an: */

    $_emails[0] = "xyz@abc.li";

    // Wenn keine $_POST Daten übermittelt wurden, dann abbrechen
    if(!isset($_POST) OR empty($_POST))
    {
       header("Content-type: text/plain; charset=utf-8");
        echo "Es wurden keine Daten übermittelt!";
        exit;
    }
    else
    {
        // Datum, Uhrzeit und Pfad zum eigenen Script feststellen
        $date = date("d.m.Y");
        $time = date("H:i");
        $host = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

        // Empfänger feststellen und auf Gültigkeit prüfen
        if(isset($_POST['recipient']) AND isset($_emails[ $_POST['recipient'] ])
           AND preg_match("/^.*@.*\..*$/", $_emails[ $_POST['recipient'] ]))
        {
            $recipient = $_emails[ $_POST['recipient'] ];
        }
        // Wurde kein (gültiger) Empfänger angegeben, es mit $_email[0] versuchen
        elseif(isset($_emails[0]) AND preg_match("/^.*@.*\..*$/", $_emails[0]))
        {
            $recipient = $_emails[0];
        }
        // Ist auch diese Adresse ungültig, mit Fehlermeldung abbrechen
        else
        {
            header("Content-type: text/plain");
            echo "Fehler im Script - es wurde kein Empfänger oder eine ungültige E-Mail Adresse in \ angegeben.";
            exit;
        }

        // Wenn Betreff übermittelt, diesen verwenden
        if(isset($_POST['subject']))
        {
            $subject = $_POST['subject'];
        }
        // sonst einen Default Betreff verwenden
        else
        {
            $subject = "Formular Daten von {$_SERVER['HTTP_HOST']}";
        }

        // E-Mai Kopf generieren
        $email = "Formular Eintrag\n"
               . "\n"
               . "Am $date um $time Uhr hast das Script auf $host Formulardaten empfangen,\n"
               . "welche nach Angabe des Browsers von {$_SERVER['HTTP_REFERER']} stammen.\n"
               . "\n"
               . "Der Formular Inhalt wird nachfolgend wiedergegeben.\n"
               . "\n";

        // Alle $_POST Werte an den E-Mail Kopf anhängen
        foreach($_POST as $key => $value)
        {
            if($key == "redirect" OR $key == "recipient" OR $key == "subject")
            {
                continue;
            }
            $email .= "Fomular Feld '$key':\n"
                   .  "=============================\n"
                   .  "$value\n"
                   .  "\n";
        }

        // E-Mail Fuß anfügen
        $email .= "=============================\n"
               .  "Ende der automatisch generierten E-Mail.";

    $email = htmlentities($email, ENT_QUOTES, 'uft-8');

        // Versuchen E-Mail zu versenden
        if(!mail($recipient, $subject, $email))
        {
            // Ist dies gescheitert, Fehlermeldung ausgeben
            echo "Es ist ein Fehler beim Versenden der E-Mail aufgetreten,"
                 . " eventuell liegt ein Konfigurationsfehler am Server vor.\n\n";
            exit;
        }

        // Wenn gewünscht, auf Bestätigungsseite weiterleiten
        if(isset($_POST['redirect']) AND preg_match("=^(http|ftp)://.*\..*$=", $_POST['redirect']))
        {
           header("Location: ".$_POST['redirect']);
            exit;
        }
        // sonst eine Bestätigung ausgeben
        else
        {
            header("Content-type: text/html");
            echo "Die E-Mail wurde erfolgreich versendet.";
        echo '<br>';
          echo '<a href="http://foto.roser.li/admin/index.php?page=kontakt">Zurueck</a>';
            exit;
        }
    }

    ?>

But now I have the problem that specific german vowels like for example ä, ö, ü or ß aren’t displayed correctly in the mail I recieve. How can I change that?

==EDIT==

Here an example:

ö ö

üß Ã¼ÃŸ

ß ÃŸ

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:51:44+00:00Added an answer on May 19, 2026 at 12:51 pm

    You need to send Content Type: UTF-8 header in email too like this:

    mail($recipient, $subject, $email,
        'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send an email from c# code via our company's exchange server.
i am trying to use this code to bind my asp.net menu control to
I often use this code pattern: while(true) { //do something if(<some condition>) { break;
I'm trying to use this code to replace spaces with _, it works for
Consider: print $foo, AAAAAAAA, $foo, BBBBBBBB; Let's say I want to use this code
If I wrote this code: typeof(myType).TypeHandle Would it use reflection? How much different from:
I'm looking at some GXT code for GWT and I ran across this use
What criteria should I use to decide whether I write VBA code like this:
In C# I use the #warning and #error directives, #warning This is dirty code...
I'm trying to use javamail in a groovy script to send out an email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.