Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Get saved search data out of Thunderbird and into plain-text file -- IMAP monitoring

by Discipulus (Canon)
on Dec 23, 2021 at 10:38 UTC ( [id://11139857]=note: print w/replies, xml ) Need Help??


in reply to Get saved search data out of Thunderbird and into plain-text file

Hello

me too I'd go for something similar to NERDVANA's ++solution: if the server is IMAP then is easier to manipulate than the client.

You can easely readapt the following code that uses Mail::IMAPClient

use strict; use warnings; use Mail::IMAPClient; use Term::ReadKey; use Getopt::Long; my $VERSION = 3; my $user; my $server; my $port; my $ssl; my $imap_folder = "INBOX"; my $sleep = 60; GetOptions ( "u|user=s" => \$user, "s|server=s" => \$server, "p|porta=i" => \$port, "ssl=i" => \$ssl, "f|folder=s" => \$imap_folder, "i|interval=i" => \$sleep, ) or show_help(); sub show_help{ print <<EOH; $0 usage: $0 -user LOGIN -server SERVER -port N [ -ssl 0|1 -folder FOLDER +-interval SECONDS ] -u -user username to authenticate to the specific server -s -server IMAP -p -port -ssl (1 or 0) -f -folder IMAP to monitor ( default: "INBOX" ) -i -interval aka sleep time between checks (default 60) EOH exit; } my %check = (user=>$user,server=>$server,port=>$port,ssl=>$ssl); foreach my $need ( keys %check ){ unless ( defined $check{$need} ){ warn "\nplease specify the parameter: $need"; show_help(); } } print "\n(termite the program using CTRL-C to permit a clean IMAP logo +ut)\n"; print "put the pwd for $user at $server\n"; my $password; ReadMode('noecho'); $password = ReadLine(0); chomp $password; ReadMode 'normal'; my $imap = Mail::IMAPClient->new( Server => $server, User => $user, password => $password, Port => $port, Ssl=> $ssl, Uid=> 1, ) or die "IMAP Failure: $@"; print "\n$user correctly authenticated on $server port $port\n". "check for new messages in $imap_folder every $sleep seconds\n +"; # Handle Ctrl-C $SIG{INT} = sub{ print "\n\nlogout..\n"; $imap->logout(); print "exiting..\n"; exit; }; $imap->Peek(1); $imap->select( $imap_folder ) or die "IMAP Select Error for imap folde +r [$imap_folder]: $@"; my $now = time; my %seen = map { $_ => 1} $imap->sentsince($now); while (1){ my @msgs = $imap->sentsince($now); foreach my $msg (@msgs){ next if $seen{$msg}; my $from = $imap->get_header( $msg, "From" ); my $subj = $imap->get_header( $msg, "Subject" ); print "New message:\n". "\tFROM: $from\n". "\tSUBJ: $subj\n"; $seen{ $msg }++; ##################################### # CHANGE HERE AS NEEDED ##################################### system(1, 'echo', "new msg from $from subj $subj"); } sleep $sleep; $now = time; }

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
  • Comment on Re: Get saved search data out of Thunderbird and into plain-text file -- IMAP monitoring
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139857]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-25 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found