格式化 Sieve 脚本以包含带有 HTML 的 MIME 的正确方法是什么?

What is the correct way to format a Sieve script to include MIME with HTML?

我正在尝试使用 Dovecot Sieve 在服务器上实现自动回复。我已经设法用简单的 html 生成了筛选脚本,但是当我尝试实现更复杂的 html 时,我收到了语法错误。

如何制定筛选脚本以允许更复杂的 html?如何修复语法错误?

:mime 参数应该用引号括起来,我想这就是它的问题所在。但是我已经尝试搜索有关如何正确编码脚本的指导,但我找不到任何指导。

例如,此代码有效...

require ["fileinto","vacation"];

vacation 
:subject "subject here" 
:mime "MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html><html><head></head><body>12345</body></html>";

但这并不...

require ["fileinto","vacation"];

vacation 
:subject "subject here" 
:mime "MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
  <meta charset="utf-8"> <!-- utf-8 works for most cases -->
  <meta name="viewport" content="width=device-width"> <!-- Forcing initial-scale shouldn't be necessary -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Use the latest (edge) version of IE rendering engine -->
  <meta name="x-apple-disable-message-reformatting"> <!-- Disable auto-scale in iOS 10 Mail entirely -->
</head>

<body width="100%" style="background: #ffffff; margin: 0; mso-line-height-rule: exactly;">
  <center style="width: 100%; background: #ffffff; text-align: left;">

    <div style="max-width: 680px; margin: auto;" class="email-container">

      <!-- Email Header : BEGIN -->
      <table role="presentation" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 680px;">
        <tr>
          <td style="padding: 40px 20px; text-align: center">
            <img src="logo.png" width="300" height="47" alt="alt_text" border="0" style="height: auto; background: #ffffff; font-family: sans-serif; font-size: 15px; line-height: 140%; color: #555555;">
          </td>
        </tr>
      </table>
      <!-- Email Header : END -->

      <!-- Email Body : BEGIN -->
      <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="max-width: 680px;" class="email-container">

        <!-- 1 Column Text : BEGIN -->
        <tr>
          <td bgcolor="#ffffff">
            <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
              <tr>
                <td style="padding: 20px; font-family: sans-serif; font-size: 15px; line-height: 140%; color: #555555;">
                  test
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <!-- 1 Column Text : END -->

      </table>
      <!-- Email Body : END -->
    </div>


    </td>
    </tr>
    </table>
  </center>
</body>

</html>";

错误信息是

Unable to parse script: script errors:
line 16: syntax error, unexpected $undefined, expecting ';'
line 68: unexpected end of file in string

您需要通过 placing a backslash before them:

转义 HTML 中的 double-quotes
require ["fileinto","vacation"];

vacation
:subject "subject here"
:mime "MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>

<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">

<head>
  <meta charset=\"utf-8\"> <!-- utf-8 works for most cases -->
  <meta name=\"viewport\" content=\"width=device-width\"> <!-- Forcing initial-scale shouldn't be necessary -->
  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"> <!-- Use the latest (edge) version of IE rendering engine -->
  <meta name=\"x-apple-disable-message-reformatting\"> <!-- Disable auto-scale in iOS 10 Mail entirely -->
</head>

<body width=\"100%\" style=\"background: #ffffff; margin: 0; mso-line-height-rule: exactly;\">
  <center style=\"width: 100%; background: #ffffff; text-align: left;\">

    <div style=\"max-width: 680px; margin: auto;\" class=\"email-container\">

      <!-- Email Header : BEGIN -->
      <table role=\"presentation\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" width=\"100%\" style=\"max-width: 680px;\">
        <tr>
          <td style=\"padding: 40px 20px; text-align: center\">
            <img src=\"logo.png\" width=\"300\" height=\"47\" alt=\"alt_text\" border=\"0\" style=\"height: auto; background: #ffffff; font-family: sans-serif; font-size: 15px; line-height: 140%; color: #555555;\">
          </td>
        </tr>
      </table>
      <!-- Email Header : END -->

      <!-- Email Body : BEGIN -->
      <table role=\"presentation\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" style=\"max-width: 680px;\" class=\"email-container\">

        <!-- 1 Column Text : BEGIN -->
        <tr>
          <td bgcolor=\"#ffffff\">
            <table role=\"presentation\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">
              <tr>
                <td style=\"padding: 20px; font-family: sans-serif; font-size: 15px; line-height: 140%; color: #555555;\">
                  test
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <!-- 1 Column Text : END -->

      </table>
      <!-- Email Body : END -->
    </div>


    </td>
    </tr>
    </table>
  </center>
</body>

</html>";