我有一个小的Perl脚本,它必须读取电子邮件的内容。脚本必须访问IMAP服务器才能读取电子邮件。我正在使用Net::IMAP::Client
模块访问IMAP服务器。
我可以访问IMAP服务器,但无法搜索收件箱。以下是尝试在收件箱中搜索电子邮件时显示的错误消息:
根据请求添加代码片段:
===============================================================
#!/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";
===============================================================
Unable to search the INBOX : [BADCHARSET (US-ASCII)] The specified charset is not supported. at PERL_Script.pl line xx, <GEN0> line 35.
有没有人能指引我解决这个问题的正确方向?
如果有更多的信息需要分享,请告诉我。
发布于 2018-08-22 03:42:20
这可能是我遇到的问题,UTF-8不会返回任何消息。
这就是解决方案。$imap->search('ALL', '', 'US-ASCII')
https://stackoverflow.com/questions/33389259
复制相似问题