RTL (Hebrew) PHP contact form problem

I host my website on a PaaS-modeled, shared hosting environment by a well known hosting provider (SiteGround) with which I never had trouble send emails to myself from contact forms in various CMSs.

I am trying to create a CMS-agnostic contact form by myself; I can submit forms with the follownig PHP code and there are no PHP errors in the browser or in an automatically-generated log file and yet no email reaches to my inbox or spam.

Is there any problem with the code?

    $name = $_POST["name"];
    $email = $_POST["email"];
    $phone = $_POST["phone"];
    $topic = $_POST["topic"];
    $date = $_POST["date"];
    $time = $_POST["time"];
    $notes = $_POST["notes"];

    $to = "example@example.com"; ########## !!! NOTE !!! ##########
    $subject = "הודעת יצירת קשר";
    $message = array (
        $name . "שם" . "\r\n",
        $email . "אימייל" . "\r\n",
        $phone . "טלפון" . "\r\n",
        $topic . "פנייה בנושא" . "\r\n",
        $date . "יום רצוי לפגישה (אם יש)" . "\r\n",
        $time . "שעה רצויה לפגישה (אם יש)" . "\r\n",
        $notes . "הערות (אם יש)" . "\r\n"

    $headers = array(
        "From" => $email,
        "Reply-To" => $email,
        "X-Mailer: PHP/" . phpversion()
    # The order should be as above: $to, $subject, $message and $headers

    mail($to, $subject, $message, $headers);

There can be problems with some hosts using PHP’s mail() function. You would be better to use PHPMailer, or something similar.

There is little point in just reassigning $_POST['name'] to $name etc without performing some sort of validation on the user input.

It would be easier to send the email with a 3rd party app, but it can be done in mail(). However, you need to fix the Hebrew Content-Type in order to do so and unfortunately that is above my pay grade.

To be honest, I don’t even know what is being done there;
My HTML includes corresponding (?) name=name, name=email, name=phone etc. attribute-value pairs in the relevant tags but I am not sure if PHP preforms any association between these HTML data and the PHP $name = $_POST["name"]; AND $name . "שם" . "\r\n", etc. data…

Hi, what is an “Hebrew Content-Type”? In plea,

Oh you meant to the form’s Content-Type: header, as in:

header("Content-Type: text/html; charset=UTF-8");


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.