Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using procmail on MUTT/IMAP
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
flickerfly
l33t
l33t


Joined: 08 Nov 2002
Posts: 677
Location: Lanham, MD

PostPosted: Fri Jun 17, 2005 2:38 am    Post subject: Using procmail on MUTT/IMAP Reply with quote

I've been playing with using mutt to check my IMAP mailbox. I like the flexibility it gives, but I want to filter messages into folders. How do I do that with this combination? Can procmail handle IMAP?
_________________
An Evil Genious' Guide to Sheeple and How To Avoid Becoming One | 0x4C9EF4A
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Fri Jun 17, 2005 12:57 pm    Post subject: Reply with quote

I don't really see how you could do this, assuming you want it all to happen on the client.

Normally, procmail is called through a local .forward, so it catches incoming mail on demand. For it to deal with IMAP folders, you'd have to do periodic polling, e.g., with fetchmail, then use procmail to sort, and somehow push the changes back to the imap server (I don't think procmail can do this, but not sure -- I'll look into it).

To sort them yourself with relatively minimal effort, you could use "hooks" in mutt, but then you still have to be the one sorting at first.


Best solution: If you have shell access on the IMAP server, then just set up a normal ".forward -> procmail -> sorted inboxes" thing there.
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Fri Jun 17, 2005 1:02 pm    Post subject: Reply with quote

actually, I can think of one way:
write a perl script using dev-perl/Mail-IMAPClient and dev-perl/Procmail
which does:
Code:

opens IMAP connection (but don't lock?)
while (watches for new mail)
    apply tests on new mail using Mail::Procmail
    put mail where it belongs


Of course, if you have a client open when this script is active, you may see messages appear and disappear in your main inbox, which might potentially confuse weak clients in some cases...
Back to top
View user's profile Send private message
raf
Apprentice
Apprentice


Joined: 16 Jan 2005
Posts: 158

PostPosted: Fri Jun 17, 2005 2:34 pm    Post subject: Reply with quote

Hi,

A bit off topic, but close enough not to warrent a new thread!

I've decided to venture into setting up e-mail on my box. Until now I have just used thunderbird, but then I cannot check my e-mail from work easily AND cannot send e-mail from scripts. So, can you tell me if I have this (seems complilcated list) right before I start?

Use fetchmail to poll my isp for my e-mail. Run in daemon mode.
Use procmail to filter my e-mail into the various mailboxes.
Use pine (or mutt?) to read and compose my e-mail.
Use sendmail to send my e-mail through my isp to its destination

If configured properly, will all this allow me to send email from scripts?


-Raf
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Fri Jun 17, 2005 2:43 pm    Post subject: Reply with quote

sure, but I'd recommend postfix, qmail, or exim as your mail server, instead on sendmail. [ Only sendmail gurus love sendmail, everyone else hates it, and if you were already a sendmail guru, you wouldn't ask this question :) ]

Actually, if your outgoing mail always relays through your ISP, you probably don't even need something like sendmail/postfix/qmail/exim, just a mail forwarder, like ssmtp.

Once you have this running, it's easy to set up an IMAP server for remote usage (like dovecot, courier, or cyrus. NOT uw-imap, which sucks). Or, you can just use pine/mutt through ssh.
Back to top
View user's profile Send private message
raf
Apprentice
Apprentice


Joined: 16 Jan 2005
Posts: 158

PostPosted: Fri Jun 17, 2005 3:16 pm    Post subject: Reply with quote

Great! Thanks for your answer.

Yes my mail would always go through my ISP, so I'm glad you said I don't need to use sendmail. I once tried to "quickly" set it up, well it was anything BUT quick. I ended up giving up as I didn't need it that badly.

-Raf
Back to top
View user's profile Send private message
darkphader
Veteran
Veteran


Joined: 09 May 2002
Posts: 1225
Location: Motown

PostPosted: Fri Jun 17, 2005 5:23 pm    Post subject: Reply with quote

I use postfix and cyrus-imap (and fetchmail to collect from my accounts). Cyrus comes with sieve which handles the filtering of incoming mail.
I had used courier with maildrop in the past but for me cyrus is the best performing imap server and there's no need to install separate filtering software like procmail or maildrop.
_________________
WYSIWYG - What You See Is What You Grep
Back to top
View user's profile Send private message
raf
Apprentice
Apprentice


Joined: 16 Jan 2005
Posts: 158

PostPosted: Mon Jun 20, 2005 1:27 pm    Post subject: Reply with quote

Hi adsmith,

One more question. Once I have fetchmail, procmail, nbsmtp, and mutt setup what is the general procedure for writing (and sending) mail through a script?

Thanks,
Raf
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Mon Jun 20, 2005 1:37 pm    Post subject: Reply with quote

emerge mailx (provides the simple "mail" program, which does command-line email), and put something like
Code:
mail -s "My Subject" me@here.org < file-with-email-body

or
Code:
echo "email body" | mail -s "My Subject" me@here.org


I might have the command-line options slightly wrong, but I think I'm right.
Back to top
View user's profile Send private message
raf
Apprentice
Apprentice


Joined: 16 Jan 2005
Posts: 158

PostPosted: Mon Jun 20, 2005 1:40 pm    Post subject: Reply with quote

Hi,

Thanks for the quick reply. Will this mail command go through my smtp to my isp and back through fetchmail? Or is it a "local" command to a user on the system?

Thanks,
Raf
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Mon Jun 20, 2005 1:46 pm    Post subject: Reply with quote

it will go through whichever MTA you installed, so probably (but depending on the behavior of your MTA), if you give it user@myhost.org, it will go through your ISP, but if you give it user@localhost, it will stay local. no promises, though... just send a couple emails with different permutations and check the headers when you get them back. mail will have the same bvehavior transport as mutt or whatever; this all dpends on the MTA.
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3522

PostPosted: Mon Jun 20, 2005 1:58 pm    Post subject: And now for something completely (well, mostly) different... Reply with quote

I revamped the email on my LAN a few months back. I now have:

fetchmail - grabs the email from my ISP, and passes it off to
postfix - runs as a local mail hub, sending outgoing mail using my ISPs relay
............- also accepts mail from fetchmail, and passes deliveries to lmtp
procmail - I tweaked the ebuild to make it act as an lmtp server, plus it filters as the user
xinetd - listens on the lmtp (2003) port and invokes procmail in lmtp mode
dovecot - imap server

The big difference in my setup is using procmail as an lmtp server. The default ebuild doesn't do that, I had to make a little tweak. (I forget exactly what, but I can check, tonight.) So postfix passes off local mail to port 2003, causing xinetd to wake procmail, which does global .procmailrc stuff, then changes itself to the user and runs the user's .procmailrc, delivering the mail as desired. I wanted to use the procmail lmtp daemon so I could completely chroot postfix. I have lmtp listening on loopback, so even if it has to run as root, it's not listening on a visible port.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Mon Jun 20, 2005 2:05 pm    Post subject: Reply with quote

interesting setup -- it's almost identical to mine, but slightly more complicated

Why do you use procmail in such a complicated way? are you doing something special with it beyond what you say here? and which chroot problems does this circumvent compared to the traditional setup?

E.g., I just have .forward -> procmail (actually perl's Mail::Procmail, which is easier to configure for my uses) on a user-by-user basis. What is the advantage of the whole port 2003 thing here?
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3522

PostPosted: Mon Jun 20, 2005 10:32 pm    Post subject: Reply with quote

adsmith wrote:
interesting setup -- it's almost identical to mine, but slightly more complicated

Why do you use procmail in such a complicated way? are you doing something special with it beyond what you say here? and which chroot problems does this circumvent compared to the traditional setup?

E.g., I just have .forward -> procmail (actually perl's Mail::Procmail, which is easier to configure for my uses) on a user-by-user basis. What is the advantage of the whole port 2003 thing here?


Whatever program delivers the mail has to be run as root, in order to setuid to the deliveree. Postfix is set up to easily chroot, (Though I actually haven't done it yet, I intend to, and am setting up to.) If a program is root, there is little point in chroot, since root can easily escape. I'm probably just gilding the lily, and there is probably sufficient separation between the parts of postfix, but I wanted to be able to chroot the whole thing, since parts of it do listen to an outside port.

Procmail ends up running as root, because it has to setuid to the deliveree, but it only listens on a loopback port.

Besides, it was a bit of a challenge figuring this out and setting it up.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Mon Jun 20, 2005 10:46 pm    Post subject: Reply with quote

okay, thanks for the info. maybe I'll try that some lazy day (though I think it's a bit paranoid, even for me)

depontius wrote:

Besides, it was a bit of a challenge figuring this out and setting it up.


8) naturally!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum