dpchen2004 2017-11-25 14:14
浏览 182
已采纳

Gmail imap-正文中的字符集错误

currently trying to use package "github.com/emersion/go-imap" in order to parse some emails however I've discovered when trying to parse emails from a specific company - they send an automated email on signup, I get returned the error "unhandled charset "ascii" when attempting the following code:

mr, err := mail.CreateReader(r)

    if err != nil {
        log.Fatal(err)
    }

the value r is assigned with the code:

msg := <-messages
    r := msg.GetBody("BODY[]")

    if r == nil {
        log.Fatal("Server didn't returned message body")
    }

which attempts to get the body of the message in my inbox. I'm not sure what's causing this error to be thrown considering every other email I've tested it on works - it's just this specific email that gets sent that causes my code to fail. I've tried having it resend and tried new email addresses. Not sure what I can do

  • 写回答

1条回答 默认 最新

  • doulou1970 2017-11-25 15:58
    关注

    That message seems to be from message.go, and probably says that go-imap only supports ASCII when it's the default, not when it's explicitly specified. In other words, Content-Type: text/plain should work, Content-Type: text/plain; charset=ascii not. The easiest way forward is probably to fix go-imap and submit a pull request.

    FYI, many old charsets have more than one name. You don't need to add support for all the legacy charsets, but for those that are supported, go-imap really should know all the names. The names are kept by IANA and this script is the kind of thing you might want to use to parse the IANA list and generate an array of aliases.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?