1

我正在尝试使用 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
4

1 回答 1

2

您将希望通过在 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>";
于 2019-06-25T17:06:55.140 回答