perl从imap消息获取所有消息头 [英] perl get all message headers from imap message

查看:73
本文介绍了perl从imap消息获取所有消息头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Mail::IMAPClient

有一些变量

$body = $imap->body_string($msg);
$header = $imap->message_string($msg);

$ body包含消息的主体,但是$ header包含消息的标题和主体.我没有在IMAPClient中找到仅获得消息头的方法.

$body contains body of message, but $header contains header and body of message. I have not found a method in IMAPClient, who get only message header.

我需要从$ header中删除正文.拆分$ body和$ header不良变体,因为body可能非常大.正文和标题将空字符串分隔开,但是我不知道如何使用它.

I need delete body from $header. Split $body and $header bad variant, because body can be very big. Body and header separates the empty string, but I do not know how to use it.

推荐答案

请查看 http://gagravarr.org/code/test-imap-headers.pl

建议 Mail::IMAPClient 软件包支持/支持关键字""ALL"一次获取所有标头:

It suggests the Mail::IMAPClient package supports/supported the 'keyword' "ALL" to get all headers at once:

my %headers = %{ $imap->parse_headers( $msg, "ALL" ) };
for my $h ( keys %headers ) {
    my @hdrs = @{ $headers{$h} };
    print "$h (" . scalar @hdrs . " entries)\n";
    foreach (@hdrs) { print "\t$_\n"; }
}

这篇关于perl从imap消息获取所有消息头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆