Groups
Sign in
Groups
Google-App-Engine-Japan
Conversations
About
Send feedback
Help
Receiving Emailについて[python編]
62 views
Skip to first unread message
yagizo
unread,
Oct 27, 2009, 3:00:10 PM
10/27/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-App-Engine-Japan
どうも、yagizoです。
Javaを使ったメール受信の投稿があったので、今更ながら
GAEでメールが受信できるようになったことに気がつきました。
で、GAE/pythonで試してみて、確かに使える、、、のですが、
ドキュメントに記載が少なくて悪戦苦闘(Pythonに慣れてない
せいもあるのですが・・・)しています。
とりあえず、
InboundReceiveHandler.receive()を使って、InboundEMailMessageを受け取る、
ところまでは割とすんなり来ました。
問題はその先です。
つまづき、その1。
InboundEMailMessage.bodies()の戻り値をどう使っていいかわからない。
これは私がPython慣れしてないから、ですかね?
とりあえず以下のようにすれば良いようです(初歩的ですいません)。
for ctype, payload in message.bodies("text/plain"):
decoded_payload=payload.decode() # メール本文
さて、問題はこの先です。
つまづき、その2。
メール本文(上記でいうところのdecoded)が、文字コードが何で書かれて
いるのかわからない。
ので、UTF-8にデコードしようがありません。
普通日本語のメールならISO-2022-JPだと思うので決め打ちでもたいていは
なんとかなるんですが気持ち悪いです。
技術屋さんならこの気持ち分かってくれると思います。
で、思ったんですが、普通のまっとうなメールクライアントなら、メールヘッダに、
Content-Type: text/plain; charset="ISO-2022-JP"
とか書くはずなんだと思うんですが、このcharsetの情報はどこに行っちゃった
んでしょうか。
payload.charsetなんて属性もありますが、Noneでした。
ctypeに入っていても良さそうな気もしますが、これはstr型で、
'text/plain'と入っているだけのものです。
根本的に何か間違っているのでしょうか。
Takashi Matsuo
unread,
Oct 27, 2009, 10:15:38 PM
10/27/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-app-...@googlegroups.com
松尾です。
ですよね!
私も気づいて本家グループに投げたけど今のところ反応はありません。
http://groups.google.com/group/google-appengine-python/browse_thread/thread/c11fea0743e0b0b7/1556e5a04de7261d
暇をみて issue を作成してみますね。
--
Takashi Matsuo
Kay's daddy
2009/10/28 yagizo <
aoy...@gmail.com
>:
yagizo
unread,
Oct 28, 2009, 12:02:19 PM
10/28/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-App-Engine-Japan
松尾さん、お返事ありがとうございます。
なるほどすでに本家のほうに質問済みだったのですね。
なんとかして欲しいですよね。
ちなみに、receive()ではなくpost()で丸ごと受けて、Python標準のemail.parser
なんかで処理させてやるとうまく行く(というより自由が利く)のかなあとは思って
ますが、時間がなくて試せてません。
issueに上がったら教えてください。投票します!
On 10月28日, 午前11:15, Takashi Matsuo <
matsuo.taka...@gmail.com
> wrote:
> 松尾です。
>
> ですよね!
>
> 私も気づいて本家グループに投げたけど今のところ反応はありません。
http://groups.google.com/group/google-appengine-python/browse_thread/.
..
Takashi Matsuo
unread,
Oct 28, 2009, 12:07:31 PM
10/28/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-app-...@googlegroups.com
松尾です。
issue 作成しました!
http://code.google.com/p/googleappengine/issues/detail?id=2326
Happy coding :-)
--
Takashi Matsuo
Kay's daddy
2009/10/29 yagizo <
aoy...@gmail.com
>:
yagizo
unread,
Oct 29, 2009, 10:42:14 AM
10/29/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-App-Engine-Japan
yagizoです。スター付けました!
なんか既にパッチまで作っちゃったんですね。すごい。
On 10月29日, 午前1:07, Takashi Matsuo <
matsuo.taka...@gmail.com
> wrote:
> 松尾です。
>
> issue 作成しました!
http://code.google.com/p/googleappengine/issues/detail?id=2326
>
> Happy coding :-)
Reply all
Reply to author
Forward
0 new messages