D
debhatta
Hi
There are two issues for which I would like your opinion. First let me
post a bit of code :
use Mail::IMAPClient;
use strict;
use diagnostics;
my $imap = Mail::IMAPClient->new(
Server => $imap_server ,
User => $user_id ,
password => $password,
Uid => 1, # Optional
) or die "cant connect to imap server, $!";
$imap->select("INBOX");
my @msgs = $imap->search("ALL");
foreach my $msg (@msgs) {
print "This is $msg\n";
my @flags = $imap->flags($msg) or die " could not flags:
$!";
my $i;
for ( $i=0;$i<@flags;$i++) {
print "The flag is $flags[$i]\n";
}
...... etc.
Say there is one message in the INBOX, then the o/p of the above code
is
This is 26006
Uncaught exception from user code:
could not flags: at auto2.pl line 51.
Can anyone tell me why its failing while retrieving the flags ? Is it
because there are no flags set ?
Secondly I want your opinion on my approach. I have a mail account
where people send their queries and I reply back. Sometimes it leads to
mail chains, for example, I can ask for more information etc. Finally
when the issue is completed I move the mails to completed. Now, what I
want is a auto-reply, which will be sent to every 'new' mail that is
received. So I do some checks as to where it came from etc. and if it
fits the criteria, I send an auto-reply and put the subject in the log
file. Next time my auto-reply script runs in a cron and if it sees a
mail, it does the same validations and checks whether the subj is
present in the log file. If iyes, I assume its an old mail and do not
send an auto-reply. It serves the purpose for most issues but fails if
two people send a mail with same subject. One then misses the
auto-reply. Can you suggest any simple mechanism without using any
extra modules ( like the auto-reply berkely db - I cannot use a db ) ?
Main problem is identifying whether the mail is a new one or seen
before ? Note that I remove mails from the inbox every now and then. I
am thinking of adding a flag to a message , which is not shown to the
user by Outlook or mozilla and then read that. To that end I was trying
the first part of my query.
Sorry for the long mail. but any suggestions welcome.
Thanks,
Raj.
There are two issues for which I would like your opinion. First let me
post a bit of code :
use Mail::IMAPClient;
use strict;
use diagnostics;
my $imap = Mail::IMAPClient->new(
Server => $imap_server ,
User => $user_id ,
password => $password,
Uid => 1, # Optional
) or die "cant connect to imap server, $!";
$imap->select("INBOX");
my @msgs = $imap->search("ALL");
foreach my $msg (@msgs) {
print "This is $msg\n";
my @flags = $imap->flags($msg) or die " could not flags:
$!";
my $i;
for ( $i=0;$i<@flags;$i++) {
print "The flag is $flags[$i]\n";
}
...... etc.
Say there is one message in the INBOX, then the o/p of the above code
is
This is 26006
Uncaught exception from user code:
could not flags: at auto2.pl line 51.
Can anyone tell me why its failing while retrieving the flags ? Is it
because there are no flags set ?
Secondly I want your opinion on my approach. I have a mail account
where people send their queries and I reply back. Sometimes it leads to
mail chains, for example, I can ask for more information etc. Finally
when the issue is completed I move the mails to completed. Now, what I
want is a auto-reply, which will be sent to every 'new' mail that is
received. So I do some checks as to where it came from etc. and if it
fits the criteria, I send an auto-reply and put the subject in the log
file. Next time my auto-reply script runs in a cron and if it sees a
mail, it does the same validations and checks whether the subj is
present in the log file. If iyes, I assume its an old mail and do not
send an auto-reply. It serves the purpose for most issues but fails if
two people send a mail with same subject. One then misses the
auto-reply. Can you suggest any simple mechanism without using any
extra modules ( like the auto-reply berkely db - I cannot use a db ) ?
Main problem is identifying whether the mail is a new one or seen
before ? Note that I remove mails from the inbox every now and then. I
am thinking of adding a flag to a message , which is not shown to the
user by Outlook or mozilla and then read that. To that end I was trying
the first part of my query.
Sorry for the long mail. but any suggestions welcome.
Thanks,
Raj.