# Particular mail setup for several users on several domains

## faceman

I'm interested in setting up a mail server in this way:

-Download mail from 10-15 accounts on different domains.

-Store them on the server to be accessed by any of 4 computers on the local network at the same time.  (How does file locking work in this regard?)

-Allow client (Thunderbird) to delete/download/etc from any computer on network.

-Allow "check email" from client to cause the mail server to check the domain server for mail.

I just need to know what is a simple but effective setup for this.  I've never set up a mail server before.

Thanks.

----------

## TheRAt

You might like to take a look at HOWTO Email System for the Home Network on the Gentoo Wiki...

----------

## faceman

I looked at that, it appears to be quite a bit more than what I need.

Really, what I want is something to pull email from a couple of accounts and make it available to clients and something to be able to send mail it recieves from the clients - basically a relay between www and localhost and single repository for several computers accessing the same accounts.

Is that what the HOWTO does?  It looks a lot bigger than that.

----------

## DaveArb

 *faceman wrote:*   

> Really, what I want is something to pull email from a couple of accounts

 

Take a look at fetchmail for this task.

 *faceman wrote:*   

> and make it available to clients

 

That will be any of several POP3 or IMAP servers. They're all pretty good, both protocols are rather simple.

 *faceman wrote:*   

> and something to be able to send mail it recieves from the clients - basically a relay between www and localhost and single repository for several computers accessing the same accounts.

 

Here you lose me a little. WWW has little to do with email. Assuming you actually meant Internet, what you've described very concisely is a mail server, like the howto described.

If these clients only wants to send mail to one location, like their ISP mailserver, it's a lot easier (and less prone to be blocked by the ISP) to set the mail client software to send directly to the ISP's mailserver.

Dave

----------

## faceman

Thanks, I'll look into it a little more, it just looked like a lot more than what I need.

I am also wary of this warning, since I'll be using at least 8 accounts and more in the future, and I'd like email to go where I send it:

 *Quote:*   

> This email system does not scale well. I can't imagine managing more than 5 accounts with the current set up as it will just become cumbersome in my opinion. When sending email using your own SMTP server, or this setup; some POP server's may regard your mail as spam and it will either be blocked entirely or filtered into a spam folder. Yahoo! is one such email service.

 

Any advice?  Or are the author's concerns here unbased?

The way I have it now is multiple computers on the network each with several accounts under Thunderbird - they're the same accounts on each computer.  Basically, what I want to do is centralize them so I have the same messages wherever I'm working, the same replies, etc, and no replication on multiple machines.

However, I use the same SMTP server for all of them, even though they're all coming from different domains.  I haven't had a problem with my ISP blocking mail thus far - would it be different if I use a mail server to send mail to the same SMTP server instead of the client I'm using now?

If I could use a single Thunderbird account folder on a server for multiple machines, that would be great, but I don't think it's possible.  So I'm looking for something really simple to do the same type of thing.

Thanks for your help.

----------

## magic919

I think the Fetchmail suggestion is great.  I'd use Postfix as MTA as I like it.  Think about anti-spam.

If you have real (not virtual) users you only need to add a user.  I've got systems with 12-15 users and find this ok.  I can see an argument for virtual and a database if you make loads of changes.

The bit about 'some POP servers' should say some SMTP servers or even LDAs to make sense.  However, get Postfix to relay the email straight to your ISP's server (works like any email client) to avoid problems with anti-spam measures.

----------

## faceman

Thank you all very much for your advice.  I'll try it out, and maybe revisit the thread if I need more help!

----------

## faceman

I've looked at the howto again, and it seems overcomplicated for my needs.

Maybe I'll start by asking dumb newbie questions, since I can't figure out (after much documentation searching and forum searching) the answers to these dumb newbie questions.

I've come to the understanding that I need a simple fetchmail & MTA setup, as suggested by magic919, but I don't know how to go about it, since the howtos I find are fairly more complicated than that.

Here are my questions:

1. If I use fetchmail only, can I read my mail that has been downloaded locally with Thunderbird?  If so, where can I find a reasonably simple howto for that?

2. Where does fetchmail store my mail?

3. Do I need an MTA?  I think I do, since I want multiple boxes to connect to one mail repository.

4. Is courier-imap simple enough for my purposes (previously stated)?

5. Where's a good howto for just a fetchmail/courier setup?

To recap my desired setup, I'd like something that fetches mail from several domains to a local server, serves the mail as IMAP to any box on the domain (and maybe login from outside the network, but that's just icing) keeping the mail in its proper mailboxes.

I will send the mail using Thunderbird to a single SMTP, so that's no problem now (Thanks, DaveArb).

Any help would be great.

----------

## magic919

 *faceman wrote:*   

> 
> 
> Here are my questions:
> 
> 1. If I use fetchmail only, can I read my mail that has been downloaded locally with Thunderbird?  If so, where can I find a reasonably simple howto for that?

 

No, Fetchmail needs an MTA.

 *Quote:*   

> 
> 
> 2. Where does fetchmail store my mail?
> 
> 

 

No.  And nor does the MTA but it knows where to put it.  The LDA (often part of the MTA) delivers the mail locally.  Gentoo-style into $HOME/.maildir

 *Quote:*   

> 
> 
> 3. Do I need an MTA?  I think I do, since I want multiple boxes to connect to one mail repository.
> 
> 

 

See above.

 *Quote:*   

> 
> 
> 4. Is courier-imap simple enough for my purposes (previously stated)?
> 
> 

 

Yes, but I use Dovecot as I find it simple.

 *Quote:*   

> 
> 
> 5. Where's a good howto for just a fetchmail/courier setup?
> 
> 

 

Maybe, but you hardly need a HOWTO.  Emerge Postfix after unmerging ssmtp.  Emerge Dovecot.  Tiny bit of config to do.  Emerge Fetchmail and work out the configs to drive it, then set-up cron jobs.  Post on here!

To recap my desired setup, I'd like something that fetches mail from several domains to a local server, serves the mail as IMAP to any box on the domain (and maybe login from outside the network, but that's just icing) keeping the mail in its proper mailboxes.

I will send the mail using Thunderbird to a single SMTP, so that's no problem now (Thanks, DaveArb).

Any help would be great.

----------

## faceman

Thanks...I'll be back.

----------

## faceman

OK, I've got fetchmail finally sucking email in from my accounts!!

I've got dovecot configured, but I don't think I'm able to log in as myself.  I telnetted to localhost 143, but I couldn't log in as my linux username/password (authentication failed).

I tried the test setup they gave in the documentation, and I logged in fine using a testuser and a password file, but I'd rather just be able to log in as myself.

The log file just said this:

 *Quote:*   

> dovecot: Mar 14 10:51:34 Info: auth(default): pam(facemyer,127.0.0.1): pam_authenticate() failed: Module is unknown
> 
> dovecot: Mar 14 10:51:44 Info: imap-login: Disconnected: user=<facemyer>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
> 
> dovecot: Mar 14 11:54:50 Info: auth(default): pam(facemyer,127.0.0.1): pam_authenticate() failed: Module is unknown

 

Any ideas?

When that's all done, do I just specify my linux username and password and "localhost" for the imap server in Thunderbird for the new account?

Thanks.

----------

## magic919

Okay.  Almost ready to rock and roll.

Sounds like you have Dovecot and no PAM.  What does

emerge -pv dovecot 

look like?  Should be a +pam in there.  Will be a case of adding the USE and a rebuild.  I'll have to upgrade to the 1.0 beta from 0.99 by the looks of mine.

----------

## magic919

And 'yes' you'll just use your Linux username and password.  Server localhost will resolve just fine.

----------

## faceman

 *Quote:*   

> localhost pam.d # emerge -pv dovecot
> 
> These are the packages that I would merge, in order:
> 
> Calculating dependencies ...done!
> ...

 

Looks like it should be there!  And I definitely have pam installed...just checked.

Maybe something in configs, but I followed the directions on dovecot's website and rechecked those, too.  Hmm...

----------

## faceman

SWEET!

I got it working by recompiling pam with +pwdb, which wasn't set before!!!

SWEET!

Now, I just need to figure out how to separate email addresses into different accounts.  I have no idea what to do to get that working, but I'm going to start looking.  Any clues?

For example, faceman@impressusart.com and joshua@magnum-enterprises.com should both be delivered to my .maildir, but into separate accounts so they are entirely distinct, but readable by my linux user (same for both).

Thanks!

----------

## magic919

Seems like it's not so much different accounts, more how to separate emails.  Conventional method for IMAP is by using folders.  You can look at Procmail or Maildrop for methods of automating the email sorting.

----------

## faceman

I need different accounts set up in Thunderbird because each one has a particular reply-to address and signature, as well as other settings.  I'd prefer to keep the sent folders, etc, separate for each one.

So, I'm thinking that I should set up a different "user" for each in fetchmail, which would mean that I couldn't use pam authentication, and would have to set up a password file for email...correct?  If I could do it another way, it would be a lot easier.  I don't want different users, just different accounts.  Can procmail or postfix do this?

----------

## magic919

Hmm.  If you are sure you can't handle this client-side then you'll need to have a re-think.  I can't see how you'd do this without creating more users (local or virtual) on the server.  Even then I can't be sure what Thunderbird will make of the sent mail, as I've never used it.

----------

## faceman

I'm trying to set up virtual users now.  I have set up a vmail directory for the basedir called /home/vmail and populated it with domains and users like this:

```
/home/vmail/domain1.com/user1

/home/vmail/domain1.com/user2

/home/vmail/domain2.com/user3

/home/vmail/domain2.com/user4
```

here's my main.cf as per the fetchmail docs:

```

virtual_mailbox_domains = domain1.com domain2.com

virtual_mailbox_base = /home/vmail

virtual_mailbox_maps = hash:/home/vmail/vmailbox

virtual_minimum_uid = 100

virtual_uid_maps = static:5000

virtual_gid_maps = static:5000

virtual_alias_maps = hash:/home/vmail/virtual

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

mail_owner = postfix

myhostname = myhost.mydomain

mydomain = mydomain

inet_interfaces = $myhostname, localhost

unknown_local_recipient_reject_code = 550

debug_peer_level = 2

debugger_command =

    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

    xxgdb $daemon_directory/$process_name $process_id & sleep 5

newaliases_path = /usr/bin/newaliases

setgid_group = postdrop

```

/home/vmail/vmailbox:

```

user1@domain1.com      domain1.com/user1

user2@domain1.com      domain1.com/user2

user3@domain2.com      domain2.com/user3

user4@domain2.com      domain2.com/user4

```

and my .fetchmailrc

```

poll mail.domain1.com proto pop3 user "user1" password "pass1" keep

poll mail.domain1.com proto pop3 user "user2" password "pass1" keep

poll mail.domain2.com proto pop3 user "user3" password "pass1" keep

poll mail.domain2.com proto pop3 user "user4" password "pass1" keep

```

Fetchmail starts to poll and gets to downloading the first message, but it gives this message just like it did before I got postfix working last time:

```

reading message user1@domain1.com:1 of 6 (1663 octets)

fetchmail: smtp listener protocol error

```

  So I imagine the problem is with postix.  I don't have any illusions that I have postfix set up corectly for virtual domains, but I've tried what appears to be an appropriate setup from the docs.  I'm probably way off base.

----------

## faceman

OK, i did 

 *Quote:*   

> 
> 
> postmap /home/vmail/vmailbox
> 
> 

 

and fetchmail downloads mail!

But it didn't put it in the /home/vmail/........ directories!  How do I find out where it is and get it to point to the right place?  I thought the setup was pretty explicit, and since it worked, the mail should be somewhere.

It gives me this:

```

fetchmail: SMTP> RCPT TO:<root@localhost>

```

and it exits with a 0 exitcode, which means it was happy.  But mail isn't in my user account, or root, or /var/spool/mail, or anywhere I can find it.

----------

## faceman

I'm going to try a new post with this info.

Edit: it's https://forums.gentoo.org/viewtopic-p-3203696.html#3203696

----------

