• <small id='TO5pX'></small><noframes id='TO5pX'>

    <tfoot id='TO5pX'></tfoot>
      <bdo id='TO5pX'></bdo><ul id='TO5pX'></ul>

    <legend id='TO5pX'><style id='TO5pX'><dir id='TO5pX'><q id='TO5pX'></q></dir></style></legend>

        <i id='TO5pX'><tr id='TO5pX'><dt id='TO5pX'><q id='TO5pX'><span id='TO5pX'><b id='TO5pX'><form id='TO5pX'><ins id='TO5pX'></ins><ul id='TO5pX'></ul><sub id='TO5pX'></sub></form><legend id='TO5pX'></legend><bdo id='TO5pX'><pre id='TO5pX'><center id='TO5pX'></center></pre></bdo></b><th id='TO5pX'></th></span></q></dt></tr></i><div id='TO5pX'><tfoot id='TO5pX'></tfoot><dl id='TO5pX'><fieldset id='TO5pX'></fieldset></dl></div>
      1. 联系表单电子邮件主题的 UTF-8 编码

        时间:2023-10-03
            <tbody id='GmwKC'></tbody>
          <i id='GmwKC'><tr id='GmwKC'><dt id='GmwKC'><q id='GmwKC'><span id='GmwKC'><b id='GmwKC'><form id='GmwKC'><ins id='GmwKC'></ins><ul id='GmwKC'></ul><sub id='GmwKC'></sub></form><legend id='GmwKC'></legend><bdo id='GmwKC'><pre id='GmwKC'><center id='GmwKC'></center></pre></bdo></b><th id='GmwKC'></th></span></q></dt></tr></i><div id='GmwKC'><tfoot id='GmwKC'></tfoot><dl id='GmwKC'><fieldset id='GmwKC'></fieldset></dl></div>

            • <small id='GmwKC'></small><noframes id='GmwKC'>

              • <legend id='GmwKC'><style id='GmwKC'><dir id='GmwKC'><q id='GmwKC'></q></dir></style></legend>
                <tfoot id='GmwKC'></tfoot>
                  <bdo id='GmwKC'></bdo><ul id='GmwKC'></ul>
                  本文介绍了联系表单电子邮件主题的 UTF-8 编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在这个网站上网站链接联系表我需要将主题发送到电子邮件UTF-8.需要在代码的什么地方声明UTF-8编码?

                  On this sites Website Link contact form I need to send the subject for email in UTF-8. Where in the code we need to do declare the UTF-8 encoding?

                  kontakt.php:

                  kontakt.php:

                  <?
                  require_once "php/sendmail.class.php";
                  $sendmail = new sendMail();
                  if ($_SERVER['REQUEST_METHOD'] == 'POST')
                  {
                  $sendmail->setParams($_POST);
                  $sendmail->parseBody();
                  $sendmail->setHeaders();
                  if ($sendmail->send())
                  {
                      header('Location: kontakt.php?success=1');
                  }
                  }
                  ?>
                  

                  sendmail.class.php:

                  sendmail.class.php:

                  class sendMail {
                  
                  var $to      = 'email'; // set contact email
                  
                  var $name    = '';
                  var $subject = '';
                  var $email   = '';
                  var $body    = '';
                  var $error   = array();
                  var $headers = array();
                  
                  function setHeaders()
                  {
                      $this->headers = "From: $this->email
                  ";
                      $this->headers.= "MIME-Version: 1.0
                  ";
                      $this->headers.= "Content-type: text/html; charset=UTF-8
                  ";
                  }
                  
                  function parseBody()
                  {
                      $message     = '<html><body>';
                      $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
                      $message .= '<tr style="background-color: #eee;"><td><strong>Name:</strong> </td><td>' . $this->name . '</td></tr>';
                      $message .= "<tr><td><strong>E-Mail-Adresse:</strong> </td><td>" . $this->email . "</td></tr>";
                      $message .= "<tr><td><strong>Betreff:</strong> </td><td>" . $this->subject . "</td></tr>";
                      $message .= "<tr><td><strong>Text:</strong> </td><td>" . $this->body . "</td></tr>";
                      $message .= "</table>";
                      $message .= "</body></html>";
                      $this->body  = $message;
                  }
                  
                  function send()
                  {
                      if ($this->error)
                      {
                          return FALSE;
                      }
                  
                      if (mail($this->to, $this->subject, $this->body, $this->headers))
                      {
                          return TRUE;
                      }
                      else
                      {
                          $this->error[] = 'Fehler beim senden';
                          return FALSE;
                      }
                  

                  在主题中,我需要 utf 8 德语字符编码.我们需要在代码的什么地方声明呢?对于消息,我发现了该怎么做,但对于主题,我没有找到解决方案.

                  In the subject I need the utf 8 german characters encoding. Where do we need to declare it in the code? For the message I found out what to do but for the subject I found no solution.

                  推荐答案

                  我是这样做的:

                  $head = "From: "=?ISO-8859-15?Q?".imap_8bit("äöüßÄÖÜ sollte hier gehen")."?=" <info@mydomain.de>
                  ";
                  $subject = "=?ISO-8859-15?Q?".imap_8bit("äöüßÄÖÜ sollte hier gehen")."?=";
                  mail($mail,$subject,$text,$head);
                  

                  这只是拉丁语 15(德语)编码.utf-8 的工作方式相同:在此处查看有关如何在邮件标头中使用字符编码的详细说明:http://ncona.com/2011/06/using-utf-8-characters-on-an-e-mail-subject/

                  that is ofc just Latin-15 (German) encoding. utf-8 works the same way: look here for a great explanation on how to use character encoding in mail headers: http://ncona.com/2011/06/using-utf-8-characters-on-an-e-mail-subject/

                  对于您的代码,您必须在 sendmail 类中进行更改:

                  for your code you have to change this in the sendmail class:

                  if (mail($this->to, '=?utf-8?B?'.base64_encode($this->subject).'?=', $this->body, $this->headers))
                  

                  !这仅在您的 php 文件是 utf-8 编码时才能正常工作!

                  ! this only works properly if your php file is utf-8 encoded !

                  还是很烦.然后我切换到 phpmailer.为你做一切.方式更容易.我建议你使用那个.

                  still very annoying. then i switched to phpmailer. that does everything for you. way more easy. i would suggest you use that.

                  这篇关于联系表单电子邮件主题的 UTF-8 编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:strlen() 和 UTF-8 编码 下一篇:dompdf 字符编码 UTF-8

                  相关文章

                  最新文章

                  <i id='lFaux'><tr id='lFaux'><dt id='lFaux'><q id='lFaux'><span id='lFaux'><b id='lFaux'><form id='lFaux'><ins id='lFaux'></ins><ul id='lFaux'></ul><sub id='lFaux'></sub></form><legend id='lFaux'></legend><bdo id='lFaux'><pre id='lFaux'><center id='lFaux'></center></pre></bdo></b><th id='lFaux'></th></span></q></dt></tr></i><div id='lFaux'><tfoot id='lFaux'></tfoot><dl id='lFaux'><fieldset id='lFaux'></fieldset></dl></div>

                  <small id='lFaux'></small><noframes id='lFaux'>

                    • <bdo id='lFaux'></bdo><ul id='lFaux'></ul>

                    <tfoot id='lFaux'></tfoot>

                      <legend id='lFaux'><style id='lFaux'><dir id='lFaux'><q id='lFaux'></q></dir></style></legend>