# Can you recommend a *SIMPLE* mail setup

## Biru

I have a Gentoo server which I use for meddling/tinkering and getting to know the system.  I have got Apache/PHP/MySQL, SSH, FTP all working fine and now I'd like to add mail.  I had hoped it would be as easy as emerge postfix then editing /etc/postfix/postfix.conf but apparently not.

Is there a simple way of getting a mail server up and running to serve no more than two or three users on my system, preferably allowing SMTP/POP3 access using existing user accounts (that is, I can log in to my email user the same credentials I would if logging into FTP or SSH).  As an aside, the server has a web accessible address using noip, and I'd like to be able to access it from the web.

Help?

----------

## Biru

I should have clarified, the reason I ask for a simple one is that I've looked at a number of HOWTO pages and they all seem geared at much larger systems with webmail access etc going on.  Perhaps later down the line I'll look at that, but right now, being able to receive emails through a normal mail client for one or two users is fine.

----------

## Veldrin

this should be possible... (i recently did it, and it seems to work; except for web access, which I do not have)

you will another program/package to provide pop3/imap functionality. I use dovecot, and am pretty happy with it. alternatively you could use cyrus. 

I can post my config, but you have to wait till tonight.

cheers

V.

----------

## Biru

Thanks.  Do all mtas require MySQL etc etc?  I want to keep this as simple as possible.

----------

## Veldrin

no at all - this just for some additional user maps, accounts et all

I use postfix, and it uses pam for authentication. 

same goes for dovecot - databases are only/foremost needed for virtual hosting.

----------

## Biru

So do I simply emerge postfix and dovecot, then edit the necessary files in /etc?

----------

## Biru

Having issues with my config file in postfix...

I'm at the mynetworks section, concerning who postfix will trust.  The problem is, I want to be able to access my mail server and send email from it wherever I am in the world.  I could be accessing the mail server from a random wifi hotspot in an airport in South America, or on a friend's home ADSL connection in Germany... I want it to be able to trust based on password authentication, not on IP ranges.  Is this possible?

----------

## Biru

To make matters worse... I'm hosting on a dynamic IP, tied to a no-ip hostname which updates at boot.  The mail server therefore is internet accessible on an address taking the form

myusername.servehttp.com

----------

## Veldrin

mynetworks is used to define network where from you can send emails without authentication.

with authentication you can send from any source.

----------

## Biru

Cheers, that does make sense.

----------

## Biru

I'm just getting nowhere here.  I'm willing to paypal someone some money to login and set up postfix etc to create a functioning mailserver for my box.  Bonus points if they log the steps as they do it to create a HOWTO for future.

----------

## cach0rr0

shouldnt be any need for that. 

to do esmtp authentication, you need to

-get postfix set up to use SASL auth

-set up your SASL database

I will help more on this in a few, have to go help someone move a fridge. Mainly posting in here so that I see it later when I click "View Your Posts"

If it helps, here is a commented/sanitized revision of my own main.cf - http://pastebin.com/raw.php?i=euB3FvS4

If I can recover data from a dead hard drive, I can put up my old wiki that documents this all in detail =/

At any rate, we can get you a functional Postfix+Dovecot setup, plus SASL auth, with relative ease. Don't abandon hope just yet!

----------

## jodel

I just posted this in another thread, but that's how to do it:

http://www.kurzor.org/entry/16/setting-up-a-mailserver-on-gentoo

----------

## cach0rr0

 *jodel wrote:*   

> I just posted this in another thread, but that's how to do it:
> 
> http://www.kurzor.org/entry/16/setting-up-a-mailserver-on-gentoo

 

slightly different from how I did it, but sensible enough I reckon 

At the moment I use something a bit more convoluted (postfix + cyrus-imap via lmtp, custom ebuild to include cyrus autocreate patch), but for a long long while I'd just add local users (e.g. useradd -m -G users -s /sbin/nologin blahuser), and I made it such that Dovecot was domain-agnostic. Email to chris@domain1.tld and chris@domain2.tld would go to the same place - /home/chris/.maildir/

no virtual mapping of any sort, 

(I forgot to include my dovecot.conf above, so here goes; too lazy to sanitize at this stage dovecot.conf )

@ Biru

hop on IRC, join #gentoo, and send me a /msg. I'll see if I can talk you through it. 

Are you ok with a setup similar to my old one, where local /etc/passwd users are your mail users? I think that's probably the easiest way. Dovecot + Postfix, local users rather than virtual users. Most straightforward setup there is. 

(NB: unless you /msg me, or type 'cach0rr0' in chan, i wont get notified.)

----------

## Biru

Hi guys and thanks again for your help.  Yeah, I'm just looking for a simple setup whereby if you have an actual login on the system, you have an associated email address on the system.  For example, I login locally as martyn, so I would like to be able to receive email at martyn@mydomain.no-ip.com.  Similarly, I would like it so that as I add users to the system, postfix is able to automatically route incoming mail to their /home/username/maildir or such.  I'm going to give jodel's tutorial a go, as it does seem pretty straightforward, and I'll let you know how I get on.  I really appreciate how helpful you guys have all been.  :Smile: 

----------

## Biru

Ok, I was able to follow jodel's tutorial no problem, but still have a few problems... the router I have is the default one sent out by my ISP.  It tries to be over friendly when it comes to portforwarding so instead of being able to specify ports manually, it lists games/applications etc... that is to say, if I chose Half Life 2, it would open 27015 or whatever it was that Half Life 2 works off.  It has entries for POP3 and SMTP, but nothing for IMAP.  So my next question is... how do I do this with POP3 and SMTP enabled as opposed to IMAP, and my second question is just one of syntax.

In /etc/postfix/main.cf  (assuming my server is on the net at mydomain.servehttp.com)

I have used the following settings:

myhostname = mydomain.servehttp.com

myorigin = servehttp.com

Am I right in doing this?  How does hosting a no-ip domain affect postfix and its config?

Thanks again guys...

----------

## cach0rr0

so to have it go to /home/<username>/.maildir/ have a look at the home_mailbox setting in my main.cf posted above. That's all you need to get the mail there. 

To pick up the mail, dovecot.conf is what needs to be changed. You could take mine verbatim, and change the protocols line as seen below:

```

protocols = pop3 

```

Not ideal, because it allows passwords to be sent cleartext, but if your router doesn't let you do real port forwarding, not sure of a way around it.

----------

## cach0rr0

 *Biru wrote:*   

> 
> 
> In /etc/postfix/main.cf  (assuming my server is on the net at mydomain.servehttp.com)
> 
> I have used the following settings:
> ...

 

You would probably need to do

```

myhostname = mydomain.servehttp.com

myorigin = $myhostname

```

for the simple fact that 'servehttp.com' is not controlled by you. 

(I'm assuming you can/have already, taken care of the requisite DNS changes needed to get mail routed to your host - it's pain with this that led me to say screw it, bought a real domain from no-ip, still use their dynamic DNS client to keep it updated)

----------

## Biru

So I've now followed the tutorial to the letter, added support for POP3, but I think there's something not right still.  Connections time out when I enable SSL and are refused when I disable SSL.    :Crying or Very sad: 

----------

## cach0rr0

pop3s is going to be on a different port (as is imaps - 995 or 993, i cant remember which of those ports is IMAP, and which is POP3), so port forwarding would still be a no-go

doing SMTP auth over TLS can take place on 25 without issue. 

When you're testing the connection, are you doing so from the local machine? Does netstat show dovecot listening?

----------

