首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法使用perl脚本(使用Net::IMAP::Client模块)获取电子邮件详细信息

无法使用perl脚本(使用Net::IMAP::Client模块)获取电子邮件详细信息
EN

Stack Overflow用户
提问于 2015-10-28 18:59:46
回答 1查看 297关注 0票数 1

我有一个小的Perl脚本,它必须读取电子邮件的内容。脚本必须访问IMAP服务器才能读取电子邮件。我正在使用Net::IMAP::Client模块访问IMAP服务器。

我可以访问IMAP服务器,但无法搜索收件箱。以下是尝试在收件箱中搜索电子邮件时显示的错误消息:

根据请求添加代码片段:

===============================================================

代码语言:javascript
复制
#!/usr/bin/perl -w

# Use this package to make sure no undefined variables are used
use strict;

# Use the following pakages for accessing the IMAP server
use Net::IMAP::Client;
use English;

my $imap = Net::IMAP::Client->new(
server => 'My.IMAP.SERVER', 
user => 'USER_Name', 
pass => 'xxxxxxxxxx', uid_mode => 1 ) or die("Could not connect to IMAP server with error code - " . $imap->Lat_error);

$imap->login or die('Login failed: ' . $imap->last_error);
my @folders = $imap->folders;
print "the content of my mailbox are : \n";
for ( my $count=0; $count <=$#folders ; $count++ )
{
    print "$folders[$count] \n";
}

# Selecting the folder
my imap->select('INBOX'); 

# fetch all message ids (as array reference)
my $messages = $imap->search('ALL') or die("Unable to search the INBOX : " . $imap -> last_error);
print "$messages \n";

===============================================================

代码语言:javascript
复制
Unable to search the INBOX : [BADCHARSET (US-ASCII)] The specified charset is not supported. at PERL_Script.pl line xx, <GEN0> line 35.

有没有人能指引我解决这个问题的正确方向?

如果有更多的信息需要分享,请告诉我。

EN

回答 1

Stack Overflow用户

发布于 2018-08-22 03:42:20

这可能是我遇到的问题,UTF-8不会返回任何消息。

这就是解决方案。$imap->search('ALL', '', 'US-ASCII')

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33389259

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档