1

我对这个电子邮件脚本的非英文字符有疑问。如果我将脚本设置为向我的 gmail 帐户发送电子邮件,我没有问题。但是,如果我将脚本设置为向我的域帐户发送电子邮件,并且如果我使用 Windows Live Mail 或 Microsoft Outlook 打开电子邮件,则该电子邮件将无法读取。我必须进入编码菜单,然后选择 utf-8,然后我才能阅读电子邮件。

如果我在 iMac 邮件客户端上打开邮件,我没有问题。

我的客户认为这是一个大问题,并希望我解决它。任何人都可以帮忙吗?

这是代码:

<?php
// send the form to the specify email

// CONFIG VARS
$subject = "mysite.com | contact form";
$to = "myaccount@somemail.com";
$from = 'another@somemail.com';


//data
$msg = "Name: "  .$_POST['namesup']    ."<br>\n";
$msg .= "Email: "  .$_POST['emailsup']    ."<br>\n";
$msg .= "Phone: "  .$_POST['phonesup']    ."<br>\n";
$msg .= "Message: "  .$_POST['yourtextsup']    ."<br>\n";

//Headers
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;


//send
mail($to, $subject, $msg, $headers);
?>

任何帮助将不胜感激。卓然

4

3 回答 3

1

签出此代码,它将对我有用,

<?php

$subject = "mysite.com | contact form";
$to = "myaccount@somemail.com";
$from = 'another@somemail.com';

 $msg = '<html>
            <head>
            </head>
                <body>
                <p>
                               Name: ".$_POST['namesup']."<br>
                               Email: ".$_POST['emailsup']."<br>
                               Phone: ".$_POST['phonesup']."<br>
                               Message: ".$_POST['yourtextsup']."<br>
                    </p>
                </body>
        </html>';

    $headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";
    $headers .= "X-Mailer: PHP \r\n";
    $headers .= "From: <".$from. ">" ;

    mail($to,$subject,$msg,$headers);
?>

这条线 $headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";解决了你喜欢阿拉伯语或其他语言的问题。

于 2013-01-17T11:25:44.280 回答
0

我建议确保您的消息是有效的 HTML,包括<html>and<head>标签,并确保您包含<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />标签。所以:

//data
$msg = '<html><head><meta http-equiv="Content-Type" content="text/html charset=UTF-8" /></head><body>';
$msg .= "Name: "  .$_POST['namesup']    ."<br>\n";
$msg .= "Email: "  .$_POST['emailsup']    ."<br>\n";
$msg .= "Phone: "  .$_POST['phonesup']    ."<br>\n";
$msg .= "Message: "  .$_POST['yourtextsup']    ."<br>\n";
$msg .= '</body></html>';
于 2013-01-17T11:14:46.163 回答
0

尝试将您的脚本字符集更改为:

<?php
// send the form to the specify email

// CONFIG VARS
$subject = "mysite.com | contact form";
$to = "myaccount@somemail.com";
$from = 'another@somemail.com';


//data
$msg = "Name: "  .$_POST['namesup']    ."<br>\n";
$msg .= "Email: "  .$_POST['emailsup']    ."<br>\n";
$msg .= "Phone: "  .$_POST['phonesup']    ."<br>\n";
$msg .= "Message: "  .$_POST['yourtextsup']    ."<br>\n";

//Headers
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1";
$headers .= "From: <".$from. ">" ;


//send
mail($to, $subject, $msg, $headers);
?>
于 2013-01-17T11:20:29.707 回答