我在网络电子邮件表单上,当我输入所有信息时它会向我发送一封电子邮件,但是当我输入一些捷克字符(该网站是捷克语)时它不起作用。例如,某些角色显示为“čřžýĂĂ”。我从一些网站上下载了免费模板,我和我认识HTML的朋友一起编辑,但不是PHP。我试图找出一些建议,但它对我没有任何意义,因为我几乎不知道关于PHP的任何事情,当我试图复制代码的某些部分并希望它能够工作时它没有...你能帮助我吗? ?
<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// Create the email and send the message
$to = 'xxxx@pl.cz'; // Add your email address inbetween the ''
replacing yourname@yourdomain.com - This is where the form will send a
message to.
$email_subject = "Website Contact Form: $name";
$email_body = "Nova zprava z webu.\n\n"."Udaje:\n\nJmeno: $name\nEmail:
$email_address\n\nMessage:\n$message";
$headers = "From: noreply@plantaen.cz\n"; // We recommend using something
like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
答案 0 :(得分:0)
将标题添加到邮件
试试这个:
$body = '<html><head><title>Title</title></head>'."\r\n";
$body .= 'Test';
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=utf-8'."\r\n";
$headers .= 'From: YourName <"from@yoruname.com">';
mail("to@yourname.com","title",$body,$headers);
编辑:
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)){
echo "No arguments Provided!";
exit();
} else {
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
$email_subject = "Website Contact Form: $name";
$email_body = '<html><head><title>plantaen</title></head>'."\r\n";
$email_body .= "Nova zprava z webu.\n\n"."Udaje:\n\nJmeno: $name\nEmail: $email_address\n\nMessage:\n$message";
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=utf-8'."\r\n";
$headers .= 'From: plantaen <"noreply@plantaen.cz">';
mail("noreply@plantaen.cz", $email_subject, $email_body, $headers);
echo "Done!";
exit();
}