LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-14-2011, 10:35 AM   #1
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint v21.3 & v22.x with Cinnamon
Posts: 1,797
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
want script to grab a specific message from IMAP server


Is there some way to grab a single message from an IMAP server with a shell script? I'd prefer to avoid "scraping" an IMAP protocol session and instead use something like wget ... with some clever options.

The second half of this question involves specification of the message that I want to retrieve. Learning a specific "message number" is messy. I will likely know the TO: and maybe the FROM: details. I might also know the SUBJECT: I'm eager for your suggestions here as well.

Merci d'avance,
~~~ 0;-Dan
 
Old 02-14-2011, 12:58 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Maybe use telnet and grab the raw data? If you would do it that way, you could possibly grep and awk for a specific pattern or string.
 
Old 02-14-2011, 03:21 PM   #3
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint v21.3 & v22.x with Cinnamon
Posts: 1,797

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by corp769 View Post
Maybe use telnet and grab the raw data? If you would do it that way, you could possibly grep and awk for a specific pattern or string.
Yeah. That telnet and raw data stuff is what I called "scraping." I was hoping that there was some 'wget' or similar one-time good-deal trick.

~~~ 0;-Dan
 
Old 02-14-2011, 03:58 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Oh my bad, I didn't understand the meaning of that word. I would rather use awk and grep, so I don't know of a way to my knowledge about using grep for that, mainly because I never mess with IMAP servers.
 
Old 02-15-2011, 10:24 PM   #5
BenLogan79
LQ Newbie
 
Registered: Feb 2011
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by SaintDanBert View Post
Yeah. That telnet and raw data stuff is what I called "scraping." I was hoping that there was some 'wget' or similar one-time good-deal trick
Dan,

wget won't help you here because it doesn't speak the IMAP protocol. The basic steps you will have to follow are
  • Log into the email server
  • Download the headers for each message.
  • Search for the message you are interested in.
  • Download the body of the message of interest.

Netcat would probably be a cleaner option than telnet. Another option would be writing a script in a language like PHP, Python or Perl. Those languages all have IMAP libraries that would make the job easier.

Do you have shell access to the IMAP server? If so, what type of server is it: cyrus, courier, etc? In most cases, your messages will be stored in plain text anyway, and you could just grep the file(s) on the server's filesystem.

Regards,
Ben
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to grab a specific branch of a driver? Yalla-One Slackware 2 06-18-2009 10:53 AM
how to grab the specific idle process from linux ahpin Linux - General 1 05-21-2008 02:42 PM
Save message in imap server folder cooljai Linux - Server 1 09-06-2007 09:28 AM
script to grab html content from between specific tags sonicthehedgehog Programming 6 01-30-2007 02:14 PM
Bouncing specific domain with specific message dlublink Linux - Software 1 08-21-2006 03:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration