我在网页上有一个php表单,它发送一个邮件到我指定的某个地址。如果我在gmail,hotmail和任何在线邮件服务中查看邮件,那么一切正常。变音符号没有问题,你可以看到šđžćč
就好了。Outlook中的PHP表单和变音标记
但是,如果我把一个邮件地址配置为来我的展望,任何变音标记将显示为一些奇怪的符号ĹžÄĹĄĹžÄ
。
我甚至尝试将邮件从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._%-][email protected][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 = '[email protected]'; //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;
}
}
?>
而且我有一个名为forma.php,我打电话给我的每一个页面上的HTML(下拉一个单独的PHP文件形式),其具有下列元件:
<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>
还有一个validate jquery的注册表单...
你如何从PHP发送邮件? – AndreKR
** Heads up!**从PHP 5.3.0开始,函数'ereg'家族已被弃用。你应该尽快停止使用它。当你在它的时候,沟通* horrid *电子邮件正则表达式并使用['filter_var'](http://php.net/filter_var)'的内部电子邮件过滤。 – Charles