Howto setup a multidrop mail server


(bob) #1

Please refer to Version2 of this HowTo

Update, 3rd May 2018. Please be aware this configuration creates backscatter spam because of using sendmail with option -t, see step 7. Please don’t follow this howto, you’ll start spamming people. I’ve worked out another way to create a multidrop mailserver and I’ll post a separate howto for it.

If you’re interested in what happens, using the option -t with sendmail tells sendmail to create a new email for everyone in the to: field of the message. That means if you receive a message with multiple address and domains in the to: field, any message to a domain which isn’t yours (e.g. domain.org.uk, step 1 below) will be forwarded on to that address by your mail server. The forwarded message is called backscatter spam.

The original post is below.

This is how I set up NethServer to use a POP3 catchall mail box at my ISP and deliver those messages to local users, with a catch all address that’s shared between users.

The setup does not use custom templates or settings that can be overwritten by the web config pages. So the mail server should be immune to changes from the web config.

Note: My ISP puts all my email into a single POP3 mailbox which conforms to the GetMail requirements for a MultiDrop mail box. See here:
http://pyropus.ca/software/getmail/configuration.html#conf-retriever-multidrop

Software & Packages:
Nethserver 7
OpenLDAP
Email
POP3 Connector
WebTop5
Nano text editor installed via the command line

  1. configure email domain on local NethServer
    Webconfig > Configuration / Email > Domain
    Click “Create New” and enter your domain name, e.g. domain.org.uk. Don’t select any other options at this point.
    Click Submit.

  2. configure users
    Webconfig > Management / Users and groups > Users
    Create your users, in my case “mum, dad, child1 and child2”.
    Create a password for each user.
    Create another user to be the CatchAll account, in my case “mail”.
    Create a password for the CatchAll account.

  3. direct unsorted mail to the CatchAll user
    Webconfig > Configuration / Email > Domain
    Edit the domain you created in step 1, select “Accept unknown recipients” and enter the address of your CatchAll user in the “deliver to” box, in my case mail@domain.org.uk
    Click Submit.

  4. configure aliases for root user – this is optional but will ensure system messages reach a real person.
    Create an email address for the root user. Select the root@YourServerName button at the top right hand corner of the Webconfig page, click Profile.
    Enter the user who will receive emails for root, e.g. dad@domain.org.uk.
    Click Submit.

  5. set up SoGo
    Login to the SoGo web interface as each of your users and the CatchAll user.
    When you are logged in to SoGo as the CatchAll user, share the inbox between your users.
    Click on the mail button, then right click on the inbox and select “Manage Sharing”.
    Select your users from the drop down list, select “Share Identity” and give them “full control”.
    In my case I have selected “Mum” and “Dad” to have full control of the “Mail” inbox.
    Click “save and close”.
    Logout of the CatchAll user and log in as “Mum” (or whatever user you selected). The shared mailbox of the CatchAll user will be visible under the entry “shared” in the list of email folders.

  6. configure the POP3 connector.
    The Webconfig does not allow a multidrop POP3 connect to be configured, so I set up what I could from the Webconfig and then edited the files from the command line.
    Webconfig > Management / POP3 Connector > Create New
    Enter an email address of a user on your machine, e.g. mum@domain.org.uk
    Enter the login details for your ISP POP3 mailbox (or IMAP mailbox if necessary).
    Deliver the messages to the email address you entered above, e.g. mum@domain.org.uk
    Select 60mins for the “check this account every” drop down.
    Select the options for spam and virus checking.
    Click submit.

  7. edit the getmail config
    Go to the command line of your server.
    Copy the config file that was created in step 6.
    cp -p /var/lib/getmail/mum@\domain.org.uk.cfg /var/lib/getmail/multidrop.cfg
    Edit the new config file to turn it into a multidrop config.
    nano /var/lib/getmail/multidrop.cfg
    make the following changes
    Change [retriever] type to MultiDropPOP3Retriever (you may need to use MultiDropPOP3SSLRetriever if you need to use SSL to get your mail)
    Add the line [retriever] envelope_recipient = X-Delivered-To:1
    Note, this line depends on how your ISP drops your email into your multidrop POP3 mailbox, you may need to use “Delivered-to:1” instead of “X-Delivered-To:1”, check the headers of your incomming mail to see where the ”to:” address is stored.
    Change [destination] path to /usr/sbin/sendmail
    Change [destination] arguments to (“-t”,”-i”,”-f %(sender)”,”%(recipient)”)
    The [retriever] and [destination] sections of the new config should look something like this:

    [retriever]
    type = MultidropPOP3Retriever
    server = your.isp.mailserver
    username = username@ispmailserver
    password = isppassword
    envelope_recipient = X-Delivered-To:1

    [destination]
    type = MDA_external
    path = /usr/sbin/sendmail
    arguments = ("-t","-i","-f %(sender)","%(recipient)")
    user = vmail
    group = vmail

  8. edit the getmail download schedule
    Go to the comand line of the your server.
    Copy the getmail cron job to a new file.
    cp -p /etc/cron.d/getmail /etc/cron.d/multidrop
    Edit the new schedule to change the frequency and refer to the correct config file.
    Nano /etc/cron.d/multidrop
    change the entry in the file to what’s shown below (which will check for messages every 2mins)
    */2 * * * * root /usr/bin/flock -n -E 0 /var/lib/getmail/multidrop.cfg -c "/usr/bin/getmail --getmaildir /var/lib/getmail/ --rcfile /var/lib/getmail/multidrop.cfg --quiet” &> /dev/null

  9. remove the POP3 connector config created in step 6.
    Webconfig > Management / POP3 Connector
    select the dropdown next to the Account you configured in step 6 and select delete.

At this point you have a Multidrop POP3 mail configuration working.
Unsorted mail is routed to the “mail” user and that mailbox is accessible by the users you configured in step 5.

Thanks to @mrmarkuz for helping with this.


(Markus Neuberger) #2

Thanks for sharing this howto! :clap: