PHP在utf-8中发送电子邮件编码

时间:2017-04-02 14:30:49

标签: php html forms email

我从php代码发送邮件时遇到问题。我想在电子邮件中使用波兰字符。我在堆栈上搜索了许多相同问题,但没有任何作用。

<?php
if(isset($_POST['submit'])){
 $to = "...@gmail.com";
 $from = $_POST['email'];
 $name = $_POST['name'];
 $phone = $_POST['phone'];
 $subject = "Wiadomość ze strony";
 $message = "Imię i Nazwisko: " . $name . "\nTelefon kontaktowy: " . $phone . "\n\nTreść wiadomości:" . "\n\n" . $_POST['msg'];

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

 mail($to,$subject,$message,$headers);
 header('Location: index.html');
}
?>

我已经要求我的朋友检查他的vps并且此代码正常工作。所以服务器一定有问题。我使用linuxpl.com。

我找到了解决方案。当我以html格式添加这一行时,波兰语字符工作正常。

accept-charset="ISO-8859-1"

1 个答案:

答案 0 :(得分:0)

04-02 18:25:55.519 11250-11250/com.android.player W/MBServiceCompat: removeSubscription for callback that isn't registered id=hhhh
04-02 18:25:55.519 11250-11250/com.android.player W/MBServiceCompat: addSubscription for callback that isn't registered id=hhhh
04-02 18:25:55.525 11250-11250/com.android.player W/MBServiceCompat: removeSubscription for callback that isn't registered id=hhhh
04-02 18:25:55.525 11250-11250/com.android.player W/MBServiceCompat: addSubscription for callback that isn't registered id=hhhh