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.

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

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器