0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

python 日本語メールボックスを操作したい

Posted at

imaplibを利用して、特定のメールボックスを操作する時に、メールボックスが日本語だとエラーになります。

原因

IMAPのメールボックス名はModified UTF-7でencodeしないといけない模様
しかし、imaplibだと対応していない・・・

検索すると、自作でうんぬんが出てくるが、めんどくさそう
https://itasuke.hatenadiary.org/entry/20120126/p1

imap_tools.imap_utf7 を利用して簡単に解決

pip install imap_tools

で imap-toolsを入れて

from imap_tools.imap_utf7 import encode  

hogehoge = encode('日本語でーす')

imapclient = imaplib.IMAP4(host,port)
imapclient.select(hogehoge)

で、問題なくメールボックスがselectできました

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?