【问题标题】:(Scala/PlayFramework) Mailgun mail gets truncated when using & in the body(Scala/Play 框架)Mailgun 邮件在使用时和正文中被截断
【发布时间】:2015-03-12 10:26:12
【问题描述】:

我在使用 html 正文中的 & 发送电子邮件时遇到了麻烦。

这是我的代码的一部分

val reqHolder: WSRequestHolder = WS.url(url).withAuth("api", apiKey, AuthScheme.BASIC)
  var responseData = Map(
    "from" -> Seq(from),
    "to" -> Seq(emailId),
    "subject" -> Seq(subject),
    "text" -> Seq(content))
  if (!htmlContent.isEmpty) {
    responseData += ("html" -> Seq(htmlContent))
  }
  val response = reqHolder.post(responseData)

对于变量 htmlContent 是这样的

htmlContent = "<html>Hi all Im trying mailgun api & testing why mi ampersand cuts my mail</html>"

当我发送电子邮件时,我得到的是“大家好,我正在尝试 mailgun api”,其余部分被 & 截断。

你能给我一个建议吗?我读到这可能是编码,但我不知道如何在 Scala 中更改编码:(。

提前致谢。

【问题讨论】:

    标签: scala email encoding mailgun truncated


    【解决方案1】:

    我认为问题出在 "&" 字符上,您可以使用:&amp 代替。

    【讨论】:

    • 这就是问题所在,我什至不能使用“&amp”,因为“&”之后的所有内容都被切断了:(
    • 我找到了解决方案。我正在使用 %26 :D
    猜你喜欢
    • 2016-05-24
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    • 2016-10-05
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多