LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Multiple pop3 accounts with Pine? (http://www.linuxquestions.org/questions/linux-software-2/multiple-pop3-accounts-with-pine-111749/)

KungFuHamster 11-03-2003 02:48 AM

Multiple pop3 accounts with Pine?
 
I've been wracking my brain trying to figure this one out: Is it possible to use Pine with more than one pop3 account? And if not, are there any command line email programs that do?

yapp 11-03-2003 07:02 AM

I would recommend setting up an IMAP server, and download all your POP3 e-mail with fetchmail. ;)

fetchmail is able to download mail, and forward it (for example, to your postfix/sendmail server). Postfix could drop the message in your ~/Maildir/ with procmail or maildrop. (both have a filtering language to sort the mail, and add spam checks / use spamassassin). An IMAP server, for example courier-imap, is able to retreive all messages from your ~/Maildir/.

And there are a lot of IMAP clients ;) including web based onces ;) (ie. you could have webmail at your own machine)

this is a bit advanced, but worth all the effort if you want something better :p

KungFuHamster 11-03-2003 11:22 AM

Know of a good place where I can find some documentation on doing this?

yapp 11-04-2003 02:41 AM

I've got a lot of help from this site: http://www.firstpr.com.au/web-mail/ but I found it very confusing. But if there is anything about this idea you're confused about, please ask :) it took me quite some time before I understood the entire concept :p

yapp 11-04-2003 05:03 AM

I just thought I could explain a little more. Because that link has way to much details :) ..this story got a little long, but I think it's useful too :p

postfix + imap
  • first try to install postfix (and uninstall sendmail). You should be able to send e-mail through postfix to another host.
    Try to use 127.0.0.1 as your SMTP server, and try to send a normal e-mail.
  • Postfix also requires you to use an aliases file. it's created by the program "newaliases". I've configured postfix to send all root@localhost mail to my own user@localhost for example ;)
  • Then you should configure the local delivery: configure postfix to use maildrop as local mail delivery agent. In other words, when you send an e-mail to you@localhost, it will be passed to maildrop. maildrop will use the ~/.mailfilter to filter the file, and store the e-mail in ~/Maildir/...
  • Get courier imap working; instead of reading the e-mail directly from ~/Maildir/, you can connect to your system on the imap port. Most e-mail programs, also outlook express support imap.

receiving mail
There are 2 ways you could receive your e-mail:
  • make the postfix server accessible from the internet, and people could send e-mail to yourusername@yourmachine. You need to be careful with this; If your system is an open-relay, spammers could use your mailserver to send messages. And every service accessible from the internet is a possible way to break into your system.
  • To retreive pop3 mail you could use "fetchmail". fetchmail downloads pop3 mail, and forwards it to postfix automatically.
  • I run fetchmail every hour from a cron-job. If my msn messenger receives a new-mail notification, fetchmail is enabled as well :)

sending mail
Sending e-mail can be done very easy; you don't need to SMTP of your ISP anymore, you can just use localhost :)

reading e-mail
you can use any IMAP capable mail client. You could use outlook express from another Windows workstation, or KMail, Mozilla-mail, mutt, or Squirllmail (webmail). It doesn't matter which client you use, the e-mail will look exactly the same! :) (even the read-status, etc.. ;))





message filtering examples
Message filtering:
From the ~/.mailfilter file, I sort all messages. Maildrop rules apply to the message text.
  • This part of my ~/.mailfilter passes the message to spamassassin, and detects the changes that spamassassin makes to spam e-mails.
    Code:

    xfilter "/usr/bin/spamassassin -x"

    if(  /^X-Spam-Flag: YES/  )
    {
      log "---- *SPAM* detected. "
      to "Maildir/.Spam"
    }

  • To filter virus e-mail, that causes outlook express to invoke attachments automatically if you only view a message!:
    Code:

    if(  $SIZE < 200000  )
    {


      # Match the <iframe> exploit of outlook express, that causes execution
      # of programs, loaded my the iframe, because on an mangled content type.
      #
      if(  /<iframe src=3D"?cid:/:b  )
      {
        log "---- *VIRUS* outlook <iframe> exploit"
        to "Maildir/.Spam"
      }


      # Remove attachments with unwanted file extensions
      # It seams another nasty trick is also popular:
      # A lot of spaces between the .ext and .pif extension.
      #
      #  Content-Type: audio/x-midi
      #  <tab>    name=file.ext      .pif
      #
      if(  /[\n\r]Content\-Type: [a-zA-Z\-\/]+;[\n\r]*[:space:]+name=.*\.(bat|pif|scr)"?[\n\r]/:bw  )
      {
        log "---- *VIRUS* unwanted extensions in content-type"
        to "Maildir/.Spam"
      }

      #  Content-Disposition: attachment; filename=file.src
      if(  /[\n\r]Content\-Disposition: attachment;[\n\r]*[:space:]+filename=.*\.(bat|pif|scr|exe)"?[\n\r]/:bw  )
      {
        log "---- *VIRUS* unwanted extensions in content-disposition"
        to "Maildir/.Spam"
      }
    }

  • Finally, this part of the code sorts a message to another folder:
    Code:

    # messages from my site to another imap folder:
    if(  /^Received: from mail\.codingdomain\.com/  )
    {
      if(  /(To|Cc|Bcc): .*webmaster@codingdomain\.com/  )
      {
        to "Maildir/.codingdomain.Inbox"
      }

      ...
    }

    # Default:
    to "Maildir/"



All times are GMT -5. The time now is 11:27 PM.