Kane David

Q: Mail forwarding in Lion

In Workgroup Manager on Snow Leopard Server when you edited a users account settings, there was a "Mail" tab which you could enable/disable the mailbox, or, have the email forwarded to an external mail account.

 

So where is the equivalent option to do this in Lion Server? I can find the option to enable mail services for the user in the Server.app, and I can add mailbox aliases (using secondary shortnames) to Workgroup Manager, but I can't find anywhere to allow mail forwarding to an external address.

 

Any ideas anyone?

Posted on Jul 31, 2011 7:40 PM

Close

Q: Mail forwarding in Lion

  • All replies
  • Helpful answers

  • by Charles Conway,

    Charles Conway Charles Conway Jul 31, 2011 9:02 PM in response to Kane David
    Level 1 (50 points)
    Jul 31, 2011 9:02 PM in response to Kane David

    Can't say for sure if there's another way to do it graphically, but you should be able to set this up in /etc/aliases.  It's a fairly standard file so you should be able to find instructios by googling.

  • by Kane David,Helpful

    Kane David Kane David Jul 31, 2011 11:54 PM in response to Kane David
    Level 1 (0 points)
    Jul 31, 2011 11:54 PM in response to Kane David

    The only way I've found to effectively do the same thing is to create an account with a local mailbox, then log in to their WebMail service and set up a filter to redirect all emails to a specified address.

     

    This works perfectly well but is a complete pain as it takes much longer to setup and I also need to know the users password.

     

    A typical case of Apple trying to make something too simple for their own good - all they end up doing is making it simple for 1% of people, and far more challenging for 99% of the rest of us. Don't know what you guys think but Lion Server seems very half baked to me.

  • by Atrato,

    Atrato Atrato Sep 15, 2011 6:46 AM in response to Kane David
    Level 1 (25 points)
    Sep 15, 2011 6:46 AM in response to Kane David

    I've solved it this way:

     

    I've created the following files in my homedirectory:

     

    -rwxr-xr-x   1 root    staff     61 Sep 15 14:59 edit_aliases.sh
    -rwxr-xr-x   1 root    staff     62 Sep 15 14:59 reload_aliases.sh
    

     

    They contain the following:

    edit_aliases.sh:
    
    #!/bin/bash
    vi /etc/aliases
    ./reload_aliases.sh
    
    reload_aliases.sh:
    
    #!/bin/bash
    postalias /etc/aliases
    newaliases 
    postfix reload
    

     

    In the aliases file I did this:

    cat /etc/aliases
    #
    # Sample aliases file. Install in the location as specified by the
    # output from the command "postconf alias_maps". Typical path names
    # are /etc/aliases or /etc/mail/aliases.
    #
    #     >>>>>>>>>>      The program "newaliases" must be run after
    #     >> NOTE >>      this file is updated for any changes to
    #     >>>>>>>>>>      show through to Postfix.
    #
    
    # Person who should get root's mail. Don't receive mail as root!
    #root:          you
    
    # Basic system aliases -- these MUST be present
    MAILER-DAEMON:     postmaster
    postmaster:     root
    
    # General redirections for pseudo accounts
    bin:          root
    daemon:          root
    named:          root
    nobody:          root
    uucp:          root
    www:          root
    ftp-bugs:     root
    postfix:     root
    
    # Put your local aliases here.
    
    # Well-known aliases
    manager:     root
    dumper:          root
    operator:     root
    
    #Custom Aliassen
    info:   localuser1, "partner@gmail.com"
    sales:  localuser1, localuser2
    ...
    

     

    When a user sends an e-mail to info@mydomain.com it is forwarded to localuser1 and to partner@gmail.com. When a users sends an e-mail to sales@mydomain.com it is forwarded to localuser1 and localuser2.

     

    I hope this helps a bit.

     

    PLEASE NOTE: Run those .sh files AS ROOT (meaning, in the terminal do sudo -s or sudo ./edit_aliases.sh)

  • by Zach Mann,

    Zach Mann Zach Mann Nov 1, 2011 1:57 PM in response to Kane David
    Level 1 (5 points)
    Nov 1, 2011 1:57 PM in response to Kane David

    Open Directory Utility on your Lion Server. Authenticate as the LDAP Admin account (usually diradmin) and edit 'groups' in LDAPv3/127.0.0.1. You can add an object type called EMailAddress for any group in LDAP. Add the accounts to the group that you would like to receive email.

  • by sydchesson,

    sydchesson sydchesson Nov 10, 2011 5:24 PM in response to Atrato
    Level 1 (10 points)
    Nov 10, 2011 5:24 PM in response to Atrato

    What a pain in the neck.  Going back to the command line for what was easy to do in the previous GUI.

     

    I agree with Kane David - that Apple play with these things and reduce the capability because someone at Apple doesn't understand or consult with the current users.

     

    Apple - pleas put the capability back to administer mail services with Work Group Manager.

  • by Zach Mann,

    Zach Mann Zach Mann Nov 11, 2011 7:47 PM in response to Zach Mann
    Level 1 (5 points)
    Nov 11, 2011 7:47 PM in response to Zach Mann

    This problem was crippling a large client after migrating from Microsoft Online Services (now Office 365) to Lion Server.

     

    Not having this feature is simply unacceptable.

     

    However, I have finalized a way to get group emails working. It involves adding the LDAP 'mail' attribute to each group that you would like to have members 'subscribed' to for group email (simply by being in that group) by doing the instructions below.

     

    Open Directory Utility on your Lion Server. Authenticate as the LDAP Admin account (usually diradmin) and edit 'groups' in LDAPv3/127.0.0.1. You can add an object type called EMailAddress for any group in LDAP. Add the accounts to the group that you would like to receive email.

     

    I preferred creating my own file called /etc/postfix/ldap-groups.cf, but you can use the provided /etc/postfix/ldap-aliases.cf if desired.

     

    In it, I put the following information to make postfix find the email address for the group, and then expand memberUid to uid, then formatting the results in an acceptable email format.

     

    /etc/postfix/ldap-groups.cf

     

    server_host = localhost

    search_base = cn=groups,dc=domain,dc=tld

    version = 3

    query_filter = (mail=%s)

    result_attribute = memberUid

    result_format = %u@domain.tld

     

    Once that is configured, you can test it by the Terminal:

     

    $ postmap -q (EMailAddress)@domain.tld ldap:/etc/postfix/ldap-groups.cf

     

    It should return users' email addresses.

     

    After that, add the following information into main.cf

     

    virtual_alias_maps = ldap:/etc/postfix/ldap-groups.cf

     

    Restart postfix

     

    # sudo postfix reload

     

    Send yourself a test email and enjoy the functionality of what should have been included in Lion Server in the first place.

     

    I am currently looking for a way to query OpenLDAP in a similar way, but instead be able to get the group email address to forward to users in it and to addresses outside of only LDAP users: e.g. forward to uid1, uid2, name(at)gmail.com.

     

    Also, being able to have some kind of rules for who can email the group ... would be nice. However, it seems that Apple has run out of nice.

  • by stephen.willis.smith,

    stephen.willis.smith stephen.willis.smith Nov 12, 2011 11:07 AM in response to Zach Mann
    Level 1 (69 points)
    Notebooks
    Nov 12, 2011 11:07 AM in response to Zach Mann

    What about the functions in server admin?

     

    Under mail - settings - mailing list you can create mailing groups.  I have tried it out seems to give the ability to only allow certain out email addresses ability to email the group,  but i am still testing it out...

  • by sydchesson,

    sydchesson sydchesson Nov 12, 2011 10:43 PM in response to stephen.willis.smith
    Level 1 (10 points)
    Nov 12, 2011 10:43 PM in response to stephen.willis.smith

    Let us know how you go.

  • by foxxus,

    foxxus foxxus Nov 22, 2011 6:19 PM in response to Kane David
    Level 1 (0 points)
    Nov 22, 2011 6:19 PM in response to Kane David

    OK, so groups can recieve mail from a group address;  can the group members then send mail under the guise of the group-assigned email alias?

     

    For example

    USERS 1,2,3, and 4 are in the "Sales" group with the group email of "sales@example.com".  If a client sends a question to sales@example.com all users in the Sales group get the email.  When they reply, will the email show up as being sent by "sales@example.com"?

     

    sincerely,

     

    OS X mail server noob

  • by Zach Mann,

    Zach Mann Zach Mann Nov 22, 2011 7:04 PM in response to foxxus
    Level 1 (5 points)
    Nov 22, 2011 7:04 PM in response to foxxus

    By going in to webmail and editing the identies to the sales address - yes. Outside of that, I don't know.

  • by foxxus,

    foxxus foxxus Nov 22, 2011 7:11 PM in response to Kane David
    Level 1 (0 points)
    Nov 22, 2011 7:11 PM in response to Kane David

    My goal is to have multiple groups and aliases for each user.  I think editting the identity in webmail would allow for only one group email alias?

     

    For example:  I am a member of the Admin, Tech Support, and Janitor groups (not really),  when I get emails from each group, I want the "from" address to be the respective address of the group email account.  I would reply to emails to the janitor group with a from address of janitor@example.com and so on...

     

    Does anyone have any tricks for this?

  • by kginger_consulting,

    kginger_consulting kginger_consulting May 7, 2012 12:00 AM in response to Zach Mann
    Level 1 (0 points)
    May 7, 2012 12:00 AM in response to Zach Mann

    Thank you Zach Mann!

     

    One word of caution though, I think if you have a group Wiki of the same name of the group you are creating email aliases for all your services will fail, at least mine did until I removed the EMailAddress object type - restarted and removed the Wiki. I then came back and added the object type and everything is fine.

  • by Peter Mundy,

    Peter Mundy Peter Mundy Mar 3, 2013 10:46 AM in response to Kane David
    Level 1 (0 points)
    Mar 3, 2013 10:46 AM in response to Kane David

    Chaps, this is well overdue now but maybe for anyone else searching for a solition here:

     

    (for unix geeks)

    man  set_user_mail_opts

     

    (for people who like reading step by step guides)

    http://support.apple.com/kb/HT5032

     

    Pete