# what would be a good mail server and how to configure it?

## genfive

I am new to linux, even newer to setting up a mail server. I have a box at home with a DSL and a router running gentoo, and uses homelinux.org to do dynamic DNS.  Would it be possible for me to set up a mail server so that I can at least send emails out, and even better to receive emails sent to me@meandmybox.homelinux.org?

I was told that sendmail is a choice, but I am not sure how to set it up.  Can someone point me to a good configuration document? Thanks.

----------

## interested1

There is a great guide on how to setup a fully working mail system with a dynamic DNS.  Check out the wiki here.  The howto comes in two parts and is based on this forum post.  I found the howto wiki really a bit too simple, but using the wiki howto and the forum post together is a great way to go.  Good luck!

----------

## genfive

 *interested1 wrote:*   

> There is a great guide on how to setup a fully working mail system with a dynamic DNS.  Check out the wiki here.  The howto comes in two parts and is based on this forum post.  I found the howto wiki really a bit too simple, but using the wiki howto and the forum post together is a great way to go.  Good luck!

 

Great! It is a bit of reading, but I will read it. Is it 100% free?  There is some HOW-TO on dynDNS site with a service called mailhop outbound, but it is not free  :Sad: 

----------

## interested1

I am pretty sure it's free.  Although to get an MX record you might have to pay, though I doubt it.

----------

## chris.c.hogan

I probably shouldn't be pointing someone new to Linux to an ebuild in in bugzilla. However, Citadel is really easy to set up. You can find the server at: https://bugs.gentoo.org/show_bug.cgi?id=62119 and the Web interface at: https://bugs.gentoo.org/show_bug.cgi?id=123139. The software homepage is at: http://www.citadel.org

The primary setup is done via emerge --config, the rest is done in the interface. You can use the CLI or Web interface.

----------

## genfive

 *chris.c.hogan wrote:*   

> I probably shouldn't be pointing someone new to Linux to an ebuild in in bugzilla. However, Citadel is really easy to set up. You can find the server at: https://bugs.gentoo.org/show_bug.cgi?id=62119 and the Web interface at: https://bugs.gentoo.org/show_bug.cgi?id=123139. The software homepage is at: http://www.citadel.org
> 
> The primary setup is done via emerge --config, the rest is done in the interface. You can use the CLI or Web interface.

 

well, here is the deal. I have a box at home uses dyndns, and I would like to install a BBS and a wiki on it, so that a few friends of mine can go there do something.  It would be nice if the system is like the real thing and has email notification capabilities, so that when someone sends another a private msg, that person will get notified in email.  The problem is, the phpBB favors sendmail.  I follow a very very brief cookbook online about how to setup sendmail under gentoo, but I don't think it is working.

so does anyone know if a quick and dirty and free way of accomplishing this task?  If not, then I will probably have to disable all the emails.

----------

## nitbix

You could try postfix, the config files are much easier to understand, and if you only want to send out it's pretty straightforward. And it has sendmail compatibility binaries, so anything that uses sendmail can use it transparently. If you have problems configuring it we are all here  :Wink:  .

----------

## genfive

 *nitbix wrote:*   

> You could try postfix, the config files are much easier to understand, and if you only want to send out it's pretty straightforward. And it has sendmail compatibility binaries, so anything that uses sendmail can use it transparently. If you have problems configuring it we are all here  .

 

I just emerged postfix and configured it according to http://www.postfix.org/BASIC_CONFIGURATION_README.html.

but I can see a pending message sitting in the /var/spool/postfix/active directory not going anywhere. 

I use DSL at home, and it connects to a dlink DI604 router. my box sits behind the router.  From the BBS, I registered a couple users using gmail address and tested it by mass mailing them. But those messages never showed up in gmail, only sitting in the active directory. 

Please help because i believe i didn't do it right  :Sad: 

----------

## interested1

You could just give all of your friends a shell accounts and then you could use a local mail system and not worry about the outbound setup.  Plus it is always fun to have multiple users on a box!

----------

## genfive

 *interested1 wrote:*   

> You could just give all of your friends a shell accounts and then you could use a local mail system and not worry about the outbound setup.  Plus it is always fun to have multiple users on a box!

 

I could do that, but isn't it more fun to have email as well?  Actually my goal is more of setting up a mail server that could send out emails than anything.

----------

## genfive

 *nitbix wrote:*   

> You could try postfix, the config files are much easier to understand, and if you only want to send out it's pretty straightforward. And it has sendmail compatibility binaries, so anything that uses sendmail can use it transparently. If you have problems configuring it we are all here  .

 

an update...  earlier I forgot to do a newalias, and that's why the email sat in the active directory.. after I did that, restarted postfix, the email got moved to the deferred directory.  in defer directory, it seems that it timed out while contacting any of the servers  (gmail, hotmail).  is this normal? or is this my setup?  also, is there a way to have the servers accept my email?

----------

## nitbix

Hmm it could be any reason. Try pasting the output of

```
# tail -n 300 /var/log/message | grep postfix
```

----------

## genfive

 *nitbix wrote:*   

> Hmm it could be any reason. Try pasting the output of
> 
> ```
> # tail -n 300 /var/log/message | grep postfix
> ```
> ...

 

thanks for sticking with me on this issue.  Now I am facing a wierd read timeout problem. I found an article on the Internet telling me how to relay to smtp.gmail.com to send and receive email, using postfix with TLS and SASL, and fetchmail.  Since I only care about sending mail, I followed the instructions to have postfix configured.  There are some discrepencies because postfix's compilation turned out to be different than what the article says, but I think it went okay. 

Later, I found that the artcle assumes gmail smtp server uses port 25, but now it uses 465.  So I added the port to where it references smtp.gmail.com.  It connects, but kept giving me a read timeout.   Could you take a look at what I did wrong and see if there is a way to fix it?

Here is the tutorial article:

http://souptonuts.sourceforge.net/postfix_tutorial.html

My postfix's LD dependency is a little different that the one posted in the tutorial, but I thought it is okay because I am not using keberose at home. below is my ldd

```

 ldd /usr/sbin/postfix

        linux-gate.so.1 =>  (0xffffe000)

        libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb7f57000)

        libssl.so.0.9.7 => /usr/lib/libssl.so.0.9.7 (0xb7f25000)

        libcrypto.so.0.9.7 => /usr/lib/libcrypto.so.0.9.7 (0xb7e26000)

        libpcre.so.0 => /usr/lib/libpcre.so.0 (0xb7df9000)

        libdb-4.2.so => /usr/lib/libdb-4.2.so (0xb7d23000)

        libnsl.so.1 => /lib/libnsl.so.1 (0xb7d0e000)

        libresolv.so.2 => /lib/libresolv.so.2 (0xb7cfc000)

        libc.so.6 => /lib/tls/libc.so.6 (0xb7be3000)

        libdl.so.2 => /lib/libdl.so.2 (0xb7bdf000)

        libcrypt.so.1 => /lib/libcrypt.so.1 (0xb7bb1000)

        libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7b9e000)

        /lib/ld-linux.so.2 (0xb7f85000)

```

Here is the contents of my /etc/hosts.  Note: tango is my laptop computer which is not even in the picture right now.

```

127.0.0.1   localhost.localdomain      localhost

192.168.0.100   alpha.sxxxx.homelinux.org alpha

192.168.0.101   tango.sxxxx.homelinux.org tango

```

my main.cf below. the tutorial doesn't even mention anything about things like myhostname, mydomain, myorigin, because it was using a fake domain which doesn't exist at all. but I am using a dyndns service, so I have configured all these parameters

```

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

mail_owner = postfix

myhostname = alpha.sxxxx.homelinux.org

mydomain = sxxxx.homelinux.org

myorigin = $mydomain

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

unknown_local_recipient_reject_code = 550

mynetworks = 192.168.0.0/24, 127.0.0.0/8

relayhost = [smtp.gmail.com]:465

alias_maps = hash:/etc/postfix/aliases

alias_database = hash:/etc/postfix/aliases

  

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

sendmail_path = /usr/sbin/sendmail

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = postdrop

html_directory = /usr/share/doc/postfix-2.2.10/html

manpage_directory = /usr/share/man

sample_directory = /etc/postfix

readme_directory = /usr/share/doc/postfix-2.2.10/readme

home_mailbox = .maildir/

disable_dns_lookups = yes

## TLS Settings

smtp_tls_loglevel = 1

smtp_tls_per_site = hash:/etc/postfix/tls_per_site

smtp_tls_CAfile = /etc/postfix/cacert.pem

smtp_tls_cert_file = /etc/postfix/alpha-cert.pem

smtp_tls_key_file = /etc/postfix/alpha-key.pem

smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache

smtp_use_tls = yes

smtpd_tls_CAfile = /etc/postfix/cacert.pem

smtpd_tls_cert_file = /etc/postfix/alpha-cert.pem

smtpd_tls_key_file = /etc/postfix/alpha-key.pem

smtpd_tls_received_header = yes

smtpd_tls_session_cache_database = btree:/var/run/smtpd_tls_session_cache

smtpd_use_tls = yes

tls_random_source = dev:/dev/urandom

## SASL Settings

smtpd_sasl_auth_enable = no

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtpd_sasl_local_domain = $myhostname

smtp_sasl_security_options = noanonymous

smtp_sasl_tls_security_options = noanonymous

smtpd_sasl_application_name = smtpd

smtp_generic_maps = hash:/etc/postfix/generic

transport_maps = hash:/etc/postfix/transport

```

contents of my sasl_passwd (of course, I have replaced the actual username and password for security):  What I am not sure here is if it is necessary to specify the port number.

```

  [smtp.gmail.com]:465   mygmailusername@gmail.com:mygmailpassword

```

Then I did the following just to match what I have in sasl_passwd (notice the port number is also specified in the key)

```

  postmap -q [smtp.gmail.com]:465 sasl_passwd

```

My generic and transport files started out with only comments from the man page, then I added the following to my generic and transport files:

```

#                                                        GENERIC(5)

root@alpha.sxxxx.homelinux.org   mygmailusername@gmail.com

```

```

#                                                      TRANSPORT(5)

gmail.com   smtp:[smtp.gmail.com]:465

alpha.sxxxx.homelinux.org   relay:[alpha.sxxxx.homelinux.org]

tango.sxxxx.homelinux.org      relay:[tango.sxxxx.homelinux.org]

```

Below is the contets of smtp_tls_per_site file:

```

smtp.gmail.com   MUST

alpha.sxxxx.homelinux.org   MUST

```

my master.cf, which has more stuff than the one posted in the tutorial. Please take a look and see if the problem is in here:

```

smtp      inet  n       -       n       -       -       smtpd

pickup    fifo  n       -       n       60      1       pickup

cleanup   unix  n       -       n       -       0       cleanup

qmgr      fifo  n       -       n       300     1       qmgr

tlsmgr    unix  -       -       n       1000?   1       tlsmgr

rewrite   unix  -       -       n       -       -       trivial-rewrite

bounce    unix  -       -       n       -       0       bounce

defer     unix  -       -       n       -       0       bounce

trace     unix  -       -       n       -       0       bounce

verify    unix  -       -       n       -       1       verify

flush     unix  n       -       n       1000?   0       flush

proxymap  unix  -       -       n       -       -       proxymap

smtp      unix  -       -       n       -       -       smtp

relay     unix  -       -       n       -       -       smtp

   -o fallback_relay=

   -o smtp_generic_maps=

showq     unix  n       -       n       -       -       showq

error     unix  -       -       n       -       -       error

discard   unix  -       -       n       -       -       discard

local     unix  -       n       n       -       -       local

virtual   unix  -       n       n       -       -       virtual

lmtp      unix  -       -       n       -       -       lmtp

anvil     unix  -       -       n       -       1       anvil

scache     unix   -   -   n   -   1   scache

maildrop  unix  -       n       n       -       -       pipe

  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}

old-cyrus unix  -       n       n       -       -       pipe

  flags=R user=cyrus argv=/usr/lib/cyrus/deliver -e -m ${extension} ${user}

cyrus     unix  -       n       n       -       -       pipe

  flags=hu user=cyrus argv=/usr/lib/cyrus/deliver -e -r ${sender} -m ${extension} ${user}

virt-cyrus     unix  -       n       n       -       -       pipe

  flags=hu user=cyrus argv=/usr/lib/cyrus/deliver -e -r ${sender} -m ${recipient} ${user}

uucp      unix  -       n       n       -       -       pipe

  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)

ifmail    unix  -       n       n       -       -       pipe

  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)

bsmtp     unix  -       n       n       -       -       pipe

  flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient

```

What I have when I do a postconf -n:

```

alias_database = hash:/etc/postfix/aliases

alias_maps = hash:/etc/postfix/aliases

command_directory = /usr/sbin

config_directory = /etc/postfix

daemon_directory = /usr/lib/postfix

debug_peer_level = 2

disable_dns_lookups = yes

home_mailbox = .maildir/

html_directory = /usr/share/doc/postfix-2.2.10/html

mail_owner = postfix

mailq_path = /usr/bin/mailq

manpage_directory = /usr/share/man

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mydomain = sxxxx.homelinux.org

myhostname = alpha.sxxxx.homelinux.org

mynetworks = 192.168.0.0/24, 127.0.0.0/8

myorigin = $mydomain

newaliases_path = /usr/bin/newaliases

queue_directory = /var/spool/postfix

readme_directory = /usr/share/doc/postfix-2.2.10/readme

relayhost = [smtp.gmail.com]:465

sample_directory = /etc/postfix

sendmail_path = /usr/sbin/sendmail

setgid_group = postdrop

smtp_generic_maps = hash:/etc/postfix/generic

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtp_sasl_security_options = noanonymous

smtp_sasl_tls_security_options = noanonymous

smtp_tls_CAfile = /etc/postfix/cacert.pem

smtp_tls_cert_file = /etc/postfix/alpha-cert.pem

smtp_tls_key_file = /etc/postfix/alpha-key.pem

smtp_tls_loglevel = 1

smtp_tls_per_site = hash:/etc/postfix/tls_per_site

smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache

smtp_use_tls = yes

smtpd_sasl_application_name = smtpd

smtpd_sasl_auth_enable = no

smtpd_sasl_local_domain = $myhostname

smtpd_tls_CAfile = /etc/postfix/cacert.pem

smtpd_tls_cert_file = /etc/postfix/alpha-cert.pem

smtpd_tls_key_file = /etc/postfix/alpha-key.pem

smtpd_tls_received_header = yes

smtpd_tls_session_cache_database = btree:/var/run/smtpd_tls_session_cache

smtpd_use_tls = yes

tls_random_source = dev:/dev/urandom

transport_maps = hash:/etc/postfix/transport

unknown_local_recipient_reject_code = 550

```

I noticed the difference because in the tutorial, postconf -n doesn't show anything about myhostname mydomain etc.  When I send out an email using sendmail, it would get stuck in the active queue, and eventually get a readtime out and moved to the deferred queueu....  Here is the tail of my syslog messages:

```

Jul 12 09:33:55 alpha postfix/qmgr[11975]: F3167410EE7: from=<daemon@sxxxx.homelinux.org>, size=1070, nrcpt=3 (queue active)

Jul 12 09:33:55 alpha postfix/smtp[14891]: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwd

Jul 12 09:33:55 alpha postfix/smtp[14892]: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwd

Jul 12 09:38:55 alpha postfix/smtp[14890]: connect to smtp.gmail.com[64.233.163.109]: read timeout (port 465)

Jul 12 09:38:55 alpha postfix/smtp[14891]: connect to smtp.gmail.com[64.233.167.111]: read timeout (port 465)

Jul 12 09:38:55 alpha postfix/smtp[14892]: connect to smtp.gmail.com[64.233.163.109]: read timeout (port 465)

Jul 12 09:40:01 alpha cron[14907]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

Jul 12 09:43:55 alpha postfix/smtp[14890]: connect to smtp.gmail.com[64.233.163.111]: read timeout (port 465)

Jul 12 09:43:55 alpha postfix/smtp[14891]: connect to smtp.gmail.com[64.233.167.109]: read timeout (port 465)

Jul 12 09:43:55 alpha postfix/smtp[14890]: 6B645410B62: to=<mygmailusername@gmail.com>, relay=none, delay=59236, status=deferred (connect to smtp.gmail.com[64.233.163.111]: read timeout)

Jul 12 09:43:55 alpha postfix/smtp[14892]: connect to smtp.gmail.com[64.233.163.111]: read timeout (port 465)

Jul 12 09:43:55 alpha postfix/smtp[14892]: F3167410EE7: to=<mygmailusername@gmail.com>, relay=none, delay=32274, status=deferred (connect to smtp.gmail.com[64.233.163.111]: read timeout)

Jul 12 09:43:55 alpha postfix/smtp[14891]: 07693410EE8: to=<mygmailusername@gmail.com>, relay=none, delay=32184, status=deferred (connect to smtp.gmail.com[64.233.167.109]: read timeout)

Jul 12 09:43:55 alpha postfix/smtp[14890]: 6B645410B62: to=<myuser2@gmail.com>, relay=none, delay=59236, status=deferred (connect to smtp.gmail.com[64.233.163.111]: read timeout)

Jul 12 09:43:55 alpha postfix/smtp[14892]: F3167410EE7: to=<myuser2@gmail.com>, relay=none, delay=32274, status=deferred (connect to smtp.gmail.com[64.233.163.111]: read timeout)

Jul 12 09:43:55 alpha postfix/smtp[14891]: 07693410EE8: to=<myuser2@gmail.com>, relay=none, delay=32184, status=deferred (connect to smtp.gmail.com[64.233.167.109]: read timeout)

Jul 12 09:43:55 alpha postfix/smtp[14890]: 6B645410B62: to=<myuser1@hotmail.com>, relay=none, delay=59236, status=deferred (connect to smtp.gmail.com[64.233.163.111]: read timeout)

Jul 12 09:43:56 alpha postfix/smtp[14891]: 07693410EE8: to=<myuser1@hotmail.com>, relay=none, delay=32185, status=deferred (connect to smtp.gmail.com[64.233.167.109]: read timeout)

Jul 12 09:43:56 alpha postfix/smtp[14892]: F3167410EE7: to=<myuser1@hotmail.com>, relay=none, delay=32275, status=deferred (connect to smtp.gmail.com[64.233.163.111]: read timeout)

Jul 12 09:50:01 alpha cron[14937]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

Jul 12 09:50:35 alpha postfix/qmgr[11975]: 0908B410B65: from=<daemon@sxxxx.homelinux.org>, size=1071, nrcpt=3 (queue active)

Jul 12 09:50:36 alpha postfix/smtp[14949]: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwd

```

any help would be appreciated !  thanks!

----------

## chris.c.hogan

 *genfive wrote:*   

> 
> 
> well, here is the deal. I have a box at home uses dyndns, and I would like to install a BBS and a wiki on it, so that a few friends of mine can go there do something.  It would be nice if the system is like the real thing and has email notification capabilities, so that when someone sends another a private msg, that person will get notified in email.  The problem is, the phpBB favors sendmail.  I follow a very very brief cookbook online about how to setup sendmail under gentoo, but I don't think it is working.
> 
> so does anyone know if a quick and dirty and free way of accomplishing this task?  If not, then I will probably have to disable all the emails.

 

Looks like you've already gone the postfix/phpBB route. However, if it proves too much trouble, Citadel offers private email, public email (BBS), mailing list, and chat functions. I'd have to read through the docs again to see if you can set up email forwarding (email notification capabilities). I'll let you know what I find. I do recall them having instructions on setting up with dyndns.

----------

## genfive

 *chris.c.hogan wrote:*   

>  *genfive wrote:*   
> 
> well, here is the deal. I have a box at home uses dyndns, and I would like to install a BBS and a wiki on it, so that a few friends of mine can go there do something.  It would be nice if the system is like the real thing and has email notification capabilities, so that when someone sends another a private msg, that person will get notified in email.  The problem is, the phpBB favors sendmail.  I follow a very very brief cookbook online about how to setup sendmail under gentoo, but I don't think it is working.
> 
> so does anyone know if a quick and dirty and free way of accomplishing this task?  If not, then I will probably have to disable all the emails. 
> ...

 

Yes, i have already gone that route, because I'd like to learn how to set them up.  But just a few minutes ago, I think I completed effed up my email system. Earlier, I noticed a warning in the syslog saying sasl_passwd.db is older than sasl_passwd.  So I did a postmap sasl_passwd, and then postmap -q [smtp.gmail.com]:465 sasl_passwd, and restarted the postfix. Now, I can no longer sendmail.  The BBS send mail would just hang there.   In my syslog messages, i also get sSMTP: Unable to connect to "mail" port 25.  WTF? I almost want to throw my box out the window!

----------

## genfive

 *nitbix wrote:*   

> Hmm it could be any reason. Try pasting the output of
> 
> ```
> # tail -n 300 /var/log/message | grep postfix
> ```
> ...

 

Can you give me some help, please? I have gone so far as setting up postfix and everything, and now all i need is how to get postfix to talk to gmail's smtp server.

----------

## langthang

can you try submission port?

```
[smtp.gmail.com]:587
```

----------

