我的邮件功能 return 成功,邮件中有法国口音时收不到邮件

My mail function return success and the mail is not received when there is french accent in the message

所以我有一个脚本可以从我网页上的表单发送邮件。用户只需输入他的邮件地址、消息和姓名。

首先我将邮件发送到我的联系地址。 (这工作正常)然后我向用户的邮件地址发送邮件。 (这不起作用)

最后一个邮件功能return成功但用户没有收到邮件。

我尝试记录所有内容,但我无法弄清楚为什么邮件可能已发送但未收到。

当我有像 "répondons" 这样的法国口音时,邮件不会发送,但当它只是 "repondons" 时它可以正常工作。我不明白为什么,但是用 accent

会更好
<?php
    // site owner
    $site_name = 'just-request.fr';
    $sender_domain = 'contact@just-request.fr';
    $to = 'contact@just-request.fr';


    // contact form fields
    $name = trim( $_POST['name'] );
    $email = trim( $_POST['email'] );
    $subject = trim( $_POST['subject'] );
    $message = trim( $_POST['message'] );


    // check for error
    $error = false;

    if ( $name === "" ) { $error = true; }

    if ( $email === "" ) { $error = true; }

    if ( $subject === "" ) { $error = true; }

    if ( $message === "" ) { $error = true; }


    // if no error, then send mail
    if ( $error == false )
    {
        $body = "Name: $name \n\nEmail: $email \n\nMessage: $message";

        $headers = "From: " . $site_name . ' <' . $sender_domain . '> ' . "\r\n";
        $headers .= "Reply-To: " . $name . ' <' . $email . '> ' . "\r\n";

        $mail_result = mail( $to, utf8_decode($subject), utf8_decode($body), $headers );

        if ( $mail_result == true )
        {
            $body = "Bonjour,\n\n";
            $body .= "Merci de votre mail, nous le prenons en compte et vous repondrons des que possible.\n\n";
            $body .= "Cordialement,\n";
            $body .= "L'equipe Request. ";

            $subject = "Réponse automatique";

            $new_mail_result = mail( $email, utf8_decode($subject), utf8_decode($body), $headers );

            if ( $new_mail_result == true )
            {
                echo 'success';
            }
            else
            {
                echo 'unsuccess';
            }
        }
        else
        {
            echo 'unsuccess';
        }
    }

    else
    {
        echo 'error';
    }

尝试使用mb_send_mail() instead of mail().
设置 mb_language() to German/de (ISO-8859-15) or English/en (ISO-8859-1).
ISO-8859-15 and ISO-8859-1 都包含法语额外字母。
ISO-8859-15 is ISO-8859-1 after Euro升级。

https://www.php.net/manual/en/function.mb-send-mail.php

Sends email. Headers and messages are converted and encoded according to the mb_language() setting. It's a wrapper function for mail(), so see also mail() for details.


评论:我想念 mb_language() option for UTF-8 with quoted-printable 编码。
对于大多数(欧洲)"almost ASCII" 特定语言的字母表来说,这会很好。