我在网页上有一个 php 表单,它将邮件发送到我指定的某个地址。如果我在 gmail、hotmail 和任何在线邮件服务中查看该邮件,一切都会正常工作。变音符号没有问题,你可以看到šđžćč
就好了。
但是,如果我将一个配置为进入我的 Outlook 的邮件地址,任何变音符号都会显示为一些奇怪的符号ĹžÄĹĄĹžÄ
。
我什至尝试将邮件从 gmail 转发到我的 Outlook 的地址,同样的事情发生了!我什至将 Outlook 中的字符编码设置UTF-8
为 ,我的表单也是如此。
这是 Outlook 中的一些奇怪故障还是我在表单中做错了什么?
任何帮助表示赞赏。
编辑:
我的 html 中有一个表单:
<?php
//If the form is submitted
if(isset($_POST['submit'])) {
//Check to make sure that the name field is not empty
if(trim($_POST['contactname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['contactname']);
}
//Check to make sure that the subject field is not empty
if(trim($_POST['subject']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['subject']);
}
if(trim($_POST['goaddress']) == '') {
$hasError = true;
} else {
$goaddress = trim($_POST['goaddress']);
}
if(trim($_POST['toaddress']) == '') {
$hasError = true;
} else {
$toaddress = trim($_POST['toaddress']);
}
if(trim($_POST['date']) == '') {
$hasError = true;
} else {
$date = trim($_POST['date']);
}
if(trim($_POST['time']) == '') {
$hasError = true;
} else {
$time = trim($_POST['time']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'random.mail@gmail.com'; //Put your own email address here
$body = "Ime i prezime: $name \n\nEmail: $email \n\nTelefon: $subject \n\nPolazišna adresa: $goaddress \n\nOdredišna adresa: $toaddress \n\nDatum: $date \n\nVrijeme: $time";
$headers = 'From: RANDOM NAME <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
}
?>
我有一个单独的 .php 文件,名为 form.php,我在每个页面(下拉表单)上调用我的 html,其中包含以下元素:
<div class="float-form">
<div class="slideToggler2" style="float;left; z-index: 100;position: absolute; cursor:pointer;">
<img style="pointer:cursor;" src="../images/naruci_en.png" />
</div>
<div class="slideContent2" style="display:none; z-index: 10;position: absolute;top:20px; ">
<div class="wrapp">
<div id="contactWrapper_en" role="form" >
<?php if(isset($hasError)) { //If errors are found ?>
<p class="error">Please check if you have filled out all the fields, and try again. Thank you.</p>
<?php } ?>
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<div class="success">
<p><strong>Email sent successfully!</strong></p>
<p>One of our agents will contact you in a little while.</p>
</div>
<?php } ?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
<div class="stage clear">
<label for="name"><strong>Full name: <em>*</em></strong></label>
<input type="text" name="contactname" id="contactname" value="" class="required" role="input" aria-required="true" />
</div>
<div class="stage clear">
<label for="email"><strong>Email: <em>*</em></strong></label>
<input type="text" name="email" id="email" value="" class="required email" role="input" aria-required="true" />
</div>
<div class="stage clear">
<label for="subject"><strong>Telephone: <em>*</em></strong></label>
<input type="text" name="subject" id="subject" value="" class="required" role="input" aria-required="true" />
</div>
<div class="stage clear">
<label for="goaddress"><strong>Starting address: <em>*</em></strong></label>
<input type="text" name="goaddress" id="goaddress" value="" class="required" role="input" aria-required="true" />
</div>
<div class="stage clear">
<label for="toaddress"><strong>Destination: <em>*</em></strong></label>
<input type="text" name="toaddress" id="toaddress" value="" class="required" role="input" aria-required="true" />
</div>
<div class="stage clear">
<label for="date"><strong>Date of departure: <em>*</em></strong></label>
<input type="text" name="date" id="date" value="" class="required" role="input" aria-required="true" />
</div>
<div class="stage clear">
<label for="time"><strong>Time of departure: <em>*</em></strong></label>
<input type="text" name="time" id="time" value="" class="required" role="input" aria-required="true" />
</div>
<p class="requiredNote"><em>*</em> Required</p>
<input type="submit" value="Send Message" name="submit" id="submitButton_en" title="Send the order!" />
</form>
</div>
</div>
</div>
</div>
还有一个验证 jquery 注册表单...