Search code examples
linuxemailpostfix-mta

Sending mail to a group in postfix


I have a group named users and users user1 and user2. I have postfix installed and I can get mail for user1@example.com and user2@example.com. Is it possible to send mail to users@examlpe.com, so group members are able to read it?

postfix is installed on ubuntu server and uses pretty much default config, just set the domains and networks and such. Users and groups are created with their home directories.


Solution

  • From the postfix manual:

    # man aliases
    ...
     Aliases
      Local Aliases
         /etc/mail/aliases is formatted as a series of lines  of  the
         form
    
         aliasname:address[, address]
    
    
         aliasname is the name of  the  alias  or  alias  group,  and
         address  is the address of a recipient in the group. Aliases
         can be nested. That is,  an  address  can  be  the  name  of
         another  alias  group.  Because of the way sendmail(1M) per-
         forms mapping from upper-case to lower-case, an address that
         is  the  name  of  another  alias group must not contain any
         upper-case letters.
    
         Lines beginning with white space are treated as continuation
         lines  for  the  preceding alias. Lines beginning with # are
         comments.
    

    You would need to manually add each user to the users group within the aliases file on your host (please check the manual for your distribution for that aliases file location).

    So, for your given example:

    # tail -1 /etc/mail/aliases
    users: user1, user2
    

    Once you have made these changes to your aliases file, run the following:

    # newaliases