# Qmail(Now Postfix),Apache,Courier and Mailman

## JC99

Greetings,

I am trying to get a mailing list up and running. I have installed and configured qmail/apache/courier/mailman. I can visit the mailman page on my website that allows you to subscribe to the mailing list. The problem arises when I try to send an email to the list. I send an email to newbie@computermailinglists.com but I get a message back that states...

 *Quote:*   

> Hi. This is the qmail-send program
> 
> I'm afraid I wasn't able to deliver your message to the following addresses.
> 
> This is a permanent error; I've given up. Sorry it didn't work out.
> ...

 

When I created the list "newbie" I was given this for aliases, but I don't know what to do with it...

```
newbie:                 "|/usr/lib/mailman/mail/mailman post newbie"

newbie-admin:           "|/usr/lib/mailman/mail/mailman admin newbie"

newbie-bounces:         "|/usr/lib/mailman/mail/mailman bounces newbie"

newbie-confirm:         "|/usr/lib/mailman/mail/mailman confirm newbie"

newbie-join:            "|/usr/lib/mailman/mail/mailman join newbie"

newbie-leave:           "|/usr/lib/mailman/mail/mailman leave newbie"

newbie-owner:           "|/usr/lib/mailman/mail/mailman owner newbie"

newbie-request:         "|/usr/lib/mailman/mail/mailman request newbie"

newbie-subscribe:       "|/usr/lib/mailman/mail/mailman subscribe newbie"

newbie-unsubscribe:     "|/usr/lib/mailman/mail/mailman unsubscribe newbie"
```

I think this problem has something to do with aliases but I am not sure. Anyone know what to do?Last edited by JC99 on Fri Jan 16, 2009 2:48 am; edited 3 times in total

----------

## boerKrelis

This is not the answer you've been waiting for, but might I suggest that if you're only just starting out your mailserver you switch to a 'modern' MTA such as Postfix? I've used qmail (with mailman) in the past, I liked it quite a lot, but the [url=http://en.wikipedia.org/wiki/Backscatter_(e-mail)]backscatter problems[/url] have made me migrate to Postfix (+gld+dspam+dovecot-lda+dovecot-imap+postfixadmin+mailman). Haven't regretted it a bit!

Anyway, you can put qmail aliases in /var/qmail/alias. Just as in the gentoo qmail howto where you set up aliases for root and postmaster.

----------

## JC99

Thanks, I hadn't heard of that backscatter problem before, I will consider switching.

Is dspam/postifx hard to setup? I may need some help, never done it before.

Can I setup domainkeys with postifx?

------------------------------------------------------

OK, I have installed postfix but it's not working. Can you please  post your main.cf so I can see what a proper configuration looks like.

I try to send a message from squirrelmail and I get his error message...

 *Quote:*   

> Message not sent. Server replied:
> 
>     Connection refused
> 
>     111 Can't open SMTP stream.

 

Solution: I got Postfix working by running ...

```
/usr/bin/newaliases
```

Here is my configuration for postfix and everything seems to work, I left the whole document untouched and just added this to the bottom of it

 *Quote:*   

> myhostname = penguin.jasoncarson.ca
> 
> mydomain = jasoncarson.ca
> 
> inet_interfaces = all
> ...

 

The "mydestination" file has the domains I accept mail for, one domain per line. I think that is the correct way, someone let me know if that is correct or not?Last edited by JC99 on Sun Jan 11, 2009 6:55 pm; edited 1 time in total

----------

## JC99

OK, now that that is over and I have switched to Postfix, what do I do next?

When I created the list "newbie" I was given this for aliases, but I don't know what to do with it...

```
newbie:                 "|/usr/lib/mailman/mail/mailman post newbie"

newbie-admin:           "|/usr/lib/mailman/mail/mailman admin newbie"

newbie-bounces:         "|/usr/lib/mailman/mail/mailman bounces newbie"

newbie-confirm:         "|/usr/lib/mailman/mail/mailman confirm newbie"

newbie-join:            "|/usr/lib/mailman/mail/mailman join newbie"

newbie-leave:           "|/usr/lib/mailman/mail/mailman leave newbie"

newbie-owner:           "|/usr/lib/mailman/mail/mailman owner newbie"

newbie-request:         "|/usr/lib/mailman/mail/mailman request newbie"

newbie-subscribe:       "|/usr/lib/mailman/mail/mailman subscribe newbie"

newbie-unsubscribe:     "|/usr/lib/mailman/mail/mailman unsubscribe newbie"
```

ok, according to the documentation that came with mailman, I did this...

 *Quote:*   

> Postfix notes
> 
> -------------
> 
> If you're using Postfix, don't manually change your /etc/mail/aliases
> ...

 

I am confused about this part of that guide...

 *Quote:*   

> Hack your Postfix's main.cf file to include the following path in your alias_maps variable:
> 
>           /usr/local/mailman/data/aliases
> 
> Note that there should be no trailing .db. Do not include this in your alias_database variable. This is because you do not want Postfix's newaliases command to modify Mailman's aliases.db file, but you do want Postfix to consult aliases.db when looking for local addresses.
> ...

 

...I tried adding the following into main.cf...

```
alias_maps = /var/lib/mailman/data/aliases

alias_maps = hash:/etc/postfix/aliases, hash:/usr/local/mailman/data/aliases

```

However, /etc/postfix/aliases and /usr/local/mailman/data/aliases don't exist but  when I add those alias_maps I can't send or receive email.

I checked inside /var/lib/mailman/data/aliases after creating a new list and the aliases look to be correct.  I still can't send messages to newbie@computermailinglists.com, when I try I get this error message sent back to me...

 *Quote:*   

> This is an automatically generated Delivery Status Notification
> 
> Delivery to the following recipient failed permanently:
> 
>     newbie@computermailinglists.com
> ...

 

----------

## boerKrelis

One of these days/weeks/months I'm going to put up an howto on how I configured stuff, since it's not exactly trivial. In the meantime, my main.cf is at the bottom of this message.

a) Have you told Postfix to accept mail for all of your domains, including computermailinglists.com? Using 'virtual_mailbox_domains', for example?

b) Have you told Postfix the right location of the mailman-generated aliases file? Mine's in /var/lib/mailman/data/virtual-mailman . Don't forget to hash it with postmap .

c) Tail /var/log/mail/current (or wherever your postfix log goes) while running your tests. Use telnet to talk to your mailserver and/or use 'mail' from the mailx package to quickly diagnose postfix' behaviour.

To increase the loglevel of Postfix, change

```

smtp      inet  n       -       -       -       -       smtpd

```

to

```

smtp      inet  n       -       -       -       -       smtpd -v

```

in master.cf.

DSPAM can be setup in so many ways it makes you cry. It took me years to arrive at a perfect setup. I use the server-mode, feed messages to it via LMTP, and use the grouping and inoculation features to let users profit from each others' efforts but keep the lusers from messing up the tokens of the users. Messages get delivered to 'plused' mailboxes, which the dovecot LDA handles quite nicely. Users' quarantine is managed via IMAP, it's a special folder which dovecot-antispam is configured to handle.

I really should make a HOWTO on this.

```

queue_directory = /var/spool/postfix                            

command_directory = /usr/sbin                                   

daemon_directory = /usr/lib/postfix                             

data_directory = /var/lib/postfix                               

mail_owner = postfix                                            

myhostname = mail.EXAMPLE.COM

mydomain = EXAMPLE.COM

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

unknown_local_recipient_reject_code = 550                             

mynetworks_style = host                                               

recipient_delimiter = +                                               

home_mailbox = .maildir/                                              

                                                                      

                                                                      

smtpd_banner = $myhostname ESMTP $mail_name - What news from the Shire?

default_destination_concurrency_limit = 8                              

debug_peer_level = 2                                                   

debugger_command =                                                     

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

         ddd $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.5.3/html                     

manpage_directory = /usr/share/man                                     

sample_directory = /etc/postfix                                        

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

virtual_transport = dovecot                                            

dovecot_destination_recipient_limit = 1                                

virtual_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf, hash:/var/lib/mailman/data/virtual-mailman

virtual_minimum_uid = 1000                                                                               

virtual_uid_maps = static:1007                                                                           

virtual_gid_maps = static:1021                                                                           

virtual_mailbox_base = /var/vmail                                                                        

virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf                               

virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf                                  

virtual_mailbox_limit = 51200000                                                                         

smtpd_sasl_auth_enable = yes                                                                             

smtpd_sasl_type = dovecot                                                                                

smtpd_sasl_path = private/auth                                                                           

smtp_use_tls = yes                                                                                       

smtp_tls_security_level = may                                                                            

smtp_tls_note_starttls_offer = yes                                                                       

smtpd_use_tls = yes                                                                                      

smtpd_tls_auth_only = yes                                                                                

smtpd_tls_key_file = /etc/ssl/postfix/server.key                                                         

smtpd_tls_cert_file = /etc/ssl/postfix/server.pem                                                        

smtpd_tls_loglevel = 1                                                                                   

smtpd_tls_received_header = yes                                                                          

smtpd_tls_session_cache_timeout = 3600s                                                                  

tls_random_source = dev:/dev/urandom                                                                     

relay_domains = permit_sasl_authenticated                                                                

smtpd_sasl_security_options = noanonymous                                                                

smtpd_restriction_classes = greylist_policy                                                              

greylist_policy = check_policy_service inet:127.0.0.1:2525                                               

smtpd_client_restrictions =

        permit_mynetworks,

        permit_sasl_authenticated,

        check_client_access hash:/etc/postfix/client_access,

        reject_rbl_client sbl-xbl.spamhaus.org,

        reject_rbl_client bl.spamcop.net,

        reject_rbl_client psbl.surriel.com

smtpd_sender_restrictions =

        permit_mynetworks,

        permit_sasl_authenticated,

        reject_non_fqdn_sender,

        reject_unknown_sender_domain,

        reject_rhsbl_sender bogusmx.rfc-ignorant.org

smtpd_recipient_restrictions =

        permit_mynetworks,

        permit_sasl_authenticated,

        reject_unauth_destination,

        reject_unlisted_recipient,

        check_recipient_access hash:/etc/postfix/greylist_optin,

        check_recipient_access pcre:/etc/postfix/dspam_optin

disable_vrfy_command = yes

alias_maps = hash:/var/lib/mailman/data/aliases, hash:/etc/mail/aliases

```

----------

## JC99

 *boerKrelis wrote:*   

> a) Have you told Postfix to accept mail for all of your domains, including computermailinglists.com? Using 'virtual_mailbox_domains', for example? 

 

My machine is using 2 domains. I sent myself an email from Gmail to both domains and I received it so I think that is set up properly.

 *boerKrelis wrote:*   

> b) Have you told Postfix the right location of the mailman-generated aliases file? Mine's in /var/lib/mailman/data/virtual-mailman . Don't forget to hash it with postmap.

 

I belive my aliases file is /var/lib/mailman/data/aliases.

What do I do here? What is a hash? What do I type into which file?

----------------------------------------------------------------------------------

OK, here is what I did, I added the following to main.cf and everything seem to be working now...

```
alias_maps = hash:/var/lib/mailman/data/aliases
```

Thanks for the pointers beorKrelis   :Smile: 

----------

## boerKrelis

Good. Now whenever you add a mailinglist, don't forget to rehash /var/lib/mailman/data/aliases by running 

```

postmap /var/lib/mailman/data/aliases

```

.

----------

## JC99

 *boerKrelis wrote:*   

> Good. Now whenever you add a mailinglist, don't forget to rehash /var/lib/mailman/data/aliases by running 
> 
> ```
> 
> postmap /var/lib/mailman/data/aliases
> ...

 

I do that and I get this...

```
penguin ~ # postmap /var/lib/mailman/data/aliases

postmap: warning: /var/lib/mailman/data/aliases, line 10: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 11: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 12: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 13: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 14: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 15: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 16: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 17: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 18: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 19: record is in "key: value" format; is this an alias file?

postmap: warning: /var/lib/mailman/data/aliases, line 22: record is in "key: value" format; is this an alias file?

```

Here is my /var/lib/mailman/data/aliases file

```
# This file is generated by Mailman, and is kept in sync with the

# binary hash file aliases.db.  YOU SHOULD NOT MANUALLY EDIT THIS FILE

# unless you know what you're doing, and can keep the two files properly

# in sync.  If you screw it up, you're on your own.

# The ultimate loop stopper address

mailman-loop: /var/lib/mailman/data/owner-bounces.mbox

# STANZA START: mailman

# CREATED: Thu Jan 15 21:37:56 2009

mailman:             "|/usr/lib/mailman/mail/mailman post mailman"

mailman-admin:       "|/usr/lib/mailman/mail/mailman admin mailman"

mailman-bounces:     "|/usr/lib/mailman/mail/mailman bounces mailman"

mailman-confirm:     "|/usr/lib/mailman/mail/mailman confirm mailman"

mailman-join:        "|/usr/lib/mailman/mail/mailman join mailman"

mailman-leave:       "|/usr/lib/mailman/mail/mailman leave mailman"

mailman-owner:       "|/usr/lib/mailman/mail/mailman owner mailman"

mailman-request:     "|/usr/lib/mailman/mail/mailman request mailman"

mailman-subscribe:   "|/usr/lib/mailman/mail/mailman subscribe mailman"

mailman-unsubscribe: "|/usr/lib/mailman/mail/mailman unsubscribe mailman"

# STANZA END: mailman

```

I followed this as per the instructions that came with mailman.

 *Quote:*   

> 6.1.1 Integrating Postfix and Mailman
> 
> You can integrate Postfix and Mailman such that when new lists are created, or lists are removed, Postfix's alias database will be automatically updated. The following are the steps you need to take to make this work.
> 
> In the description below, we assume that you've installed Mailman in the default location, i.e. /usr/local/mailman. If that's not the case, adjust the instructions according to your use of configure's --prefix and --with-var-prefix options.
> ...

 

ok, I tried doing everything manually and instead of following that guide but I still get the same problem with postmap.Last edited by JC99 on Sat Jan 17, 2009 2:53 am; edited 4 times in total

----------

## cach0rr0

just in case this is the least bit helpful, here are my configs for pretty much everything

https://whitehathouston.com/topics/index.php/WHHMail

Seems like the only thing lingering for you now though, is the inability to postmap that file

indeed looking at it, format doesn't appear to be as expected by postmap. Normal aliases snippet:

```

MAILER-DAEMON:      honeypot

postmaster:        honeypot

adm:                honeypot

bin:                honeypot

daemon:             honeypot

exim:               honeypot

lp:                 honeypot

mail:               honeypot

named:              honeypot

```

obviously that's not the whole thing, but you get the idea

----------

## JC99

ok, if I remove everything including spaces and run "postmap /var/lib/mailman/data/aliases" it works...

```
mailman:"|/usr/lib/mailman/mail/mailman post mailman"

mailman-admin:"|/usr/lib/mailman/mail/mailman admin mailman"

mailman-bounces:"|/usr/lib/mailman/mail/mailman bounces mailman"

mailman-confirm:"|/usr/lib/mailman/mail/mailman confirm mailman"

mailman-join:"|/usr/lib/mailman/mail/mailman join mailman"

mailman-leave:"|/usr/lib/mailman/mail/mailman leave mailman"

mailman-owner:"|/usr/lib/mailman/mail/mailman owner mailman"

mailman-request:"|/usr/lib/mailman/mail/mailman request mailman"

mailman-subscribe:"|/usr/lib/mailman/mail/mailman subscribe mailman"

mailman-unsubscribe:"|/usr/lib/mailman/mail/mailman unsubscribe mailman"
```

----------

## boerKrelis

Could be I was wrong and you need to run 'newaliases' instead of 'postmap /bla/foo/bla'.

----------

## JC99

 *boerKrelis wrote:*   

> Could be I was wrong and you need to run 'newaliases' instead of 'postmap /bla/foo/bla'.

 

I don't think I have to do either. I created a new test list, sent some test emails and everything worked.

----------

## boerKrelis

I was just rummaging through some mailman logs and I discovered that Mailman itself makes the aliasdb. It does a

```

/usr/sbin/postalias /var/lib/mailman/data/aliases

```

Thought I'd mention it here.

----------

