# [SOLVED]Get mail by POP3, access by IMAP/webmail-best combo?

## Havin_it

Hi,

My mail collection is getting quite large, and I'm at a point where there's more coming in that I want to archive, so I'm thinking about moving mail collection and storage duties onto my home server.

This would involve collecting mail regularly from a number of accounts via POP3 (bunging it all through Spamassassin in the process if possible), which I'd then access via IMAP using Thunderbird on my laptop while at home, or via secure IMAP or webmail while out and about.  Single sign-on for accessing the various accounts would be a plus.  Outgoing mail would be sent through my ISP's SMTP server (requiring authentication, natch) with an appropriate from-address among the configured receiving accounts.

I've been looking over the info about MTAs here and on Wikipedia, and it seems there's a dizzying array of combinations you could adopt for something like this. Can anyone recommend a good combination that would tick all the boxes above, while keeping good security on the WAN side? I already have LAMP setup, so it would be easy enough to involve those in the configuration.

Any advice very gratefully accepted.Last edited by Havin_it on Fri Mar 07, 2008 2:26 pm; edited 1 time in total

----------

## aronparsons

net-mail/fetchmail

net-mail/dovecot

mail-mta/ssmtp

That combination should do what you want with minimal configuration.

----------

## Havin_it

Hi, thanks for the recommendations! Quite a bit of reading to do now I guess (even with the 'minimal configuration' options   :Wink:   ) so I'll be back on when I've had a bash setting these up.

In the meantime two questions:

1) Can I import my old mail from Thunderbird into dovecot maildirs?

2) I only know of Squirrelmail for webmail (it's what my web hosts use). Are there any other good options out there?

----------

## bunder

 *Havin_it wrote:*   

> 2) I only know of Squirrelmail for webmail (it's what my web hosts use). Are there any other good options out there?

 

there's imp...

http://www.horde.org/imp/

but i prefer squirrelmail myself.

cheers

----------

## Havin_it

Mm, imp looks a lot more spiffy than Squirrelmail -- though I immediately suspect that means it'll be harder to configure correctly   :Confused:   I guess I may toy with both of them.

I started installing and trying to configure the three packages listed above. Fetchmail seems simple enough, I've already got one low-volume account configured in it, now I just need to setup something to receive the mail. Now this is where I think I may be in need of a little better understanding...

Is ssmtp used between fetchmail and dovecot, or does dovecot accept the messages straight from fetchmail? (I'd assumed ssmtp was only used for sending outgoing mail.)

As I mentioned I would like to run spamassassin (and I forgot also clamav) over the incoming mail. I assume this happens somewhere between fetchmail and dovecot?

----------

## aronparsons

SSMTP will only be for outgoing.  As for SpamAssassin and ClamAV, I'm not real sure where those fit in (I haven't played with them in ~4 years).  If they can just run standalone over a mail file or directory (e.g. mbox or /var/spool/mail), then logically it fits in between fetchmail and dovecot.

----------

## gentoo_dude

My settings are fetchmail / postfix / courier-imap / squirrelmail.  I use fetchmail to retrieve other organizations e-mails (including google), postfix to my own domain and logs and such from my computers, courier-imap to use a mail client from laptop or pine on the computer, squirrelmail to access via the https when I don't have my e-mail client available.

I do not use email filtering of junk except using the e-mail client rules.

----------

## Havin_it

I'm certainly willing to look at alternative configurations if necessary, but I've spent half the night poring over dovecot and fetchmail so I certainly want to see if I can make these work first of all   :Smile: 

The problem I have right now is how to get fetchmail to transfer the mail to dovecot. I opted for virtual user setup based on this page:

http://wiki.dovecot.org/HowTo/SimpleVirtualInstall

...and set up deliver using this page:

http://wiki.dovecot.org/LDA

...but what do I enter in fetchmailrc to get the mail delivered to the named user?

UPDATE:

With a bit more reading, things came together very quickly! I made my fetchmailrc like so:

```

set logfile "/var/log/mail"

set postmaster "postmaster"

set nobouncemail

set no spambounce

set properties ""

poll mail.thejoyoftux.net with proto POP3 auth password

       user 'pop3user' there with password 'wouldntyouliketoknow' is 'mymailuser' here options no rewrite

    mda  "/usr/libexec/dovecot/deliver -d mymailuser"

```

What I didn't get (and couldn't readily discern from the fetchmail manpage) was the idea of invoking a program command as opposed to a port or socket.

I was able to install Squirrelmail quite quickly (very user-friendly setup) and login with the dovecot credentials to view the mail fetchmail had downloaded. I could create new folders etc. and update my "From" address without issues too.

I've abandoned the idea of using a single IMAP account to manage multiple POP3 accounts; it's counterintuitive, and it's not really that much effort to switch between them when necessary.

ssmtp setup was also pretty easy, though it's worth noting (since the manpage doesn't bother  :Razz:  ) that to use my ISP's server with SMTP AUTH I had to add the following lines to /etc/ssmtp/ssmtp.conf

```

mailhub=post.example.com

#Had to add these two lines

AuthUser=myusername

AuthPass=smtppass

#comment out this line...

#rewriteDomain=

# ...and uncomment this one so whatever the IMAP client sends as "From" is left alone.

# Note: some ISPs won't permit this if the outgoing hostname is different

FromLineOverride=YES

```

Next I tried setting up access to the account using Thunderbird, and this seems to have worked fine too. I'm even able to drag'n'drop messages from my Thunderbird local folders into the IMAP folders, so I don't need to worry about migration problems  :Very Happy: 

One thing I notice: it seems that it's the IMAP client that takes care of sending the mail, meaning that this has to be configured for each client (and in some cases might not be feasible, e.g. sending from different untrusted locations). Is there a way that all outgoing mails can be routed automatically to the sendmail on the server, rather than from the client's location?

----------

## Havin_it

Right, I think I have a better handle on it now. ssmtp is not right for my situation, because when I'm "abroad" with my own laptop I'd want to use my home server to send emails from Thunderbird (my ISP SMTP server won't let me send email from other locations).  I can access the IMAP and SMTP ports on the server with ssh port-forwarding, but then I need a listening SMTP server, which ssmtp doesn't do.

So I actually do need a slightly more beefy MTA such as Exim, Postfix etc. Any recommendations here? As before, security and simple configuration are preferred.

----------

## Havin_it

And the winner is... postfix!

Well, there was no contest as such; I just decided it had a bigger volume of web documentation than Exim and more people seemed to be using it with dovecot. As with dovecot, the size of the annotated config-file was greatly scary -- and the blocks of configuration you need to set up SASL (both incoming and outgoing) aren't even present, so you have to read around and find out what to add -- but in the end I was surprised how quickly I got up and running.

There are a few finishing touches to do; I still need to set up some spam and virus filtering of incoming mail, but I think I'll investigate those by myself.  I do now feel confident enough to copy my archived mail across from Thunderbird and start using it full-time. All in all, I'm pleased that things were so easy  :Very Happy: 

----------

