Qmail forwarding to two email addresses

Discussion in 'qmail' started by Snowstorm, Dec 23, 2013.

  1. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    Hi,

    Currently I have qmail set up just to receive and forward emails for to a different mail server, where the actual user mailboxes reside. Qmail does not store any user email, just forwards it to the second mail server.

    The second mail server is down due to massive power failure - temporarily I would like to forward incoming emails to gmail accounts.

    Where can I add the gmail forwarding accounts for the users?

    Config files:

    /etc/qmail/rcpthosts: mydomain.com

    /etc/qmail/defaultdelivery: ./Maildir/

    /etc/qmail/smtproutes: mydomain.com:10.10.10.15

    /etc/qmail/goodrcptto: x.y@mydomain.com, a.b@mydomain.com, etc.


    Where can I add to send users emails to two email addresses?

    x.y@mydomain.com x.y@gmail.com
    a.b@mydomain.com a.b.@gmail.com

    Thank you, appreciated.
     


  2. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    9,002
    Likes Received:
    120
    Where and how is the existing forwarding configured?

    .qmail files in the user home dirs?

    Virtual domains configured in part from the /var/qmail/users dir?

    Static forwards configured from the /var/qmail/alias dir?

    :welcome: to Email Questions!
     

  3. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    Thank you for the quick reply - highly appreciated!

    I am not sure:

    .qmail files in the user home dirs?
    - there are no local users related to the email addresses, all email addresses are just added to: /etc/qmail/goodrcptto


    Virtual domains configured in part from the /var/qmail/users dir?
    - /var/qmail/users directory empty

    Static forwards configured from the /var/qmail/alias dir?
    - in /var/qmail/alias directory only local system users:

    lrwxrwxrwx 1 root qmail 11 2010-08-10 16:18 .qmail-abuse -> .qmail-root
    lrwxrwxrwx 1 root qmail 11 2010-08-10 16:18 .qmail-mailer-daemon -> .qmail-root
    -rw-r--r-- 1 root qmail 20 2010-08-10 16:18 .qmail-postmaster
    -rw-r--r-- 1 root qmail 20 2010-08-10 16:18 .qmail-root

    .qmail-root and .qmail-postmaster has sysadmin@mydomain.com

    Thank you again!
     
  4. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    9,002
    Likes Received:
    120
    How did qmail get installed on this server?

    Is it life with qmail directions?

    Did it come with a control panel such as Plesk?

    Did you build yourself from source?

    What does an ls -la inside of /var/qmail look like?
     
  5. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    9,002
    Likes Received:
    120
    Better question, if you needed to create a new forward, how would you do it?

    That should quickly get us to the right place to update the existing forwards.
     
  6. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    I suspect it was installed from source - years ago, by someone else, there is no control panel.

    This is /var/qmail dir:

    drwxr-sr-x 2 alias qmail 4096 2010-08-10 16:38 alias
    drwxr-xr-x 2 root qmail 4096 2009-05-04 21:14 bin
    drwxr-xr-x 2 root qmail 4096 2008-12-03 12:21 boot
    lrwxrwxrwx 1 root root 10 2008-12-03 12:18 control -> /etc/qmail
    drwxr-xr-x 2 root qmail 4096 2008-12-03 12:21 doc
    drwxr-xr-x 10 root qmail 4096 2008-12-03 12:21 man
    -rw-r--r-- 1 root root 46 2010-01-08 09:30 qmail.tar.bz
    drwxr-x--- 11 qmailq qmail 4096 2010-01-08 09:50 queue
    -rwxr-xr-x 1 root root 215 2008-12-03 12:27 rc
    drwxr-xr-x 4 root root 4096 2008-12-03 12:28 supervise
    drwxr-xr-x 2 root qmail 4096 2008-12-03 12:21 users

    These seem to be the installation sources:

    rwxr-xr-x 2 root root 4096 2009-01-19 19:25 cdb-0.75
    -rw-r--r-- 1 root root 54162 2000-02-19 15:47 cdb-0.75.tar.gz
    -rw-r--r-- 1 root root 36975 2001-07-12 12:58 daemontools-0.76.tar.gz
    -rwxr-xr-x 1 root root 21719 2008-07-14 22:53 mkvalidrcptto
    drwxr-xr-x 2 root daemon 28672 2009-01-19 19:23 qmail-1.03
    -rw-r--r-- 1 root root 250033 2008-06-02 21:57 qmail-1.03-jms1.7.07.patch
    -rw-r--r-- 1 root root 220668 2009-01-19 18:56 qmail-1.03.tar.gz


    Thanks!
     
  7. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    This qmail server receives emails from outside, but forwards them only to the second (local) email server via VPN. (as defined in /etc/qmail/smtproutes)

    The accepted and forwarded users are listed in /etc/qmail/goodrcptto
     
  8. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    9,002
    Likes Received:
    120
    What does ls -la of /var/qmail/control look like?
     
  9. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    lrwxrwxrwx 1 root root 10 2008-12-03 12:18 /var/qmail/control -> /etc/qmail

    /etc/qmail:

    -rw-r--r-- 1 root root 14 2008-12-03 12:31 bouncefrom
    -rw-r--r-- 1 root root 3 2009-12-01 15:43 concurrencyincoming
    -rw-r--r-- 1 root root 3 2009-12-01 15:43 concurrencyremote
    -rw-r--r-- 1 root root 11 2008-12-03 12:31 defaultdelivery
    -rw-r--r-- 1 root root 11 2008-12-03 12:31 defaultdomain
    lrwxrwxrwx 1 root root 33 2008-12-03 12:34 goodrcptto -> /var/rsync/qmail/goodrcptto.imail
    -rwxr-xr-x 1 root root 4685 2011-04-13 13:07 goodrcptto-bkp-20110413
    -rw-r--r-- 1 root root 3899 2008-12-03 12:31 goodrcptto.old
    -rw-r--r-- 1 root root 0 2008-12-03 12:31 locals
    -rw-r--r-- 1 root root 16 2010-08-10 16:43 me
    -rw-r--r-- 1 root root 11 2008-12-03 12:31 plusdomain
    -rw-r--r-- 1 root root 191 2012-08-27 15:59 rcpthosts
    -rw-r--r-- 1 root root 403 2012-09-17 11:26 smtproutes
    -rw-r--r-- 1 root root 2 2010-01-08 09:16 spfbehavior
     
  10. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    9,002
    Likes Received:
    120
    What are the contents of the smtproutes file?

    Is it possible this server forwards all email accepted, and has a sort of deny all but allow only a couple good email addresses that get forwarded policy, instead of having specific forwards for each user?

    If that's the case I think you would need to temporarily override that behavior with local forwards to get the email somewhere else for now.
     
  11. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    /etc/smtproutes:
    mydomain.com: 10.10.10.15

    "Is it possible this server forwards all email accepted, and has a sort of deny all but allow only a couple good email addresses that get forwarded policy, instead of having specific forwards for each user?"

    This seems to be the case. Other than the good list (/etc/qmail/goodrcptto) the user email addresses are not listed. Each new user needs to be added to this list, otherwise the second mail server does not receive it. But that's all that needed.
     
  12. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    I have found this about the qmail patch - it describes what you were guessing...


    "The problem it sets out to solve is that qmail downloads the entire message before rejecting it if it is not for a valid address on the system. I have worked around this by having a file called control/goodrcptto which lists all the allowed addresses that mail can be recieved for, so the message is rejected based on the SMTP envelope when the RCPT TO command is recieved. The reason for this patch is that about 90% of the mail I recieve is for non existant users on a domain I own which is a simple mistype away from the domain used by a US cable ISP for all it's customer email addresses. More fool me for not checking befor registering it but I have to live with it now!

    The solution is not elegant! You must create a file called goodrcptto in the qmail control directory. This can list acceptable email addresses in the following forms:

    full address ie someone@somedomain.com means that email that is for someone@somedomain.com will be accepted
    domains ie @otherdomain.com means that all mail @otherdomain.com will be accepted
    usernames ie foo means that any mail addressed to foo at any of the domains for which mail is accepted by this server is accepted (domains usually listed in control/me or control/rcpthosts or control/locals)
    It solves my problem of downloading entire messages then bouncing them (often to have the bounce bounced) admirably and has vastly cut down on the amount of bandwidth I use.

    Note that obviously every time a user or alias is added the goodrcptto file must be updated or their mail will be bounced. Checking the user list and .qmail files instead of using a separate file which must be manually updated is a "thing to do"."

    http://www.chater.demon.co.uk/qmail/
     
  13. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    9,002
    Likes Received:
    120
    Who is your domain name registered with? Most domain registrars, like Godaddy, offer free email forwarding with a domain. I think the easiest (and possibly permanent) solution is to create the forwards with your registrar and repoint the MX for the domain to their mail servers. That will get the forwards working again and you won't need this server to handle forwarding their email.

    Does this server do anything else? You might actually be able to do this as a permanent solution and retire a server if the only thing it does is handle the forwarding for those users.
     
  14. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    Unfortunately the server where I want to forward is down due to power failure.

    I would like to use this qmail (which normally acts as the "secondary" MX) to pick up mail (while "primary" MX mail server is down) and forward to temporary gmail addresses, while the "primary" MX is back online.

    I was hoping that I can just add easily the gmail addresses to the existing user emails and qmail would forward them to both location (even though only gmail would pick it up right now).
     
  15. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    9,002
    Likes Received:
    120
    I don't want to risk messing up the secondary backup-mx which is why I suggested the registrar. I see that suggestion was a little wrong since the primary is down, but I do like going down a similar path.

    Can you create the couple accounts you need at the registrar and replace the existing MX records? They won't be forwards, they will be actual email accounts. The only MX record would be the name of the service that is temporarily hosting those addresses.

    That would get you working accounts, and no changes would be needed to the existing environments. Then, when the power is restored where your primary MX server is you can go back to those original primary and backup-mx records.

    If you really prefer to have the secondary server forward somewhere else try creating .qmail files in the /var/qmail/alias dir, make sure the domain is configured as local within /var/qmail/control, and check your qmail logs for errors after the changes.
     
  16. Snowstorm

    Snowstorm New Email

    Joined:
    Dec 23, 2013
    Messages:
    9
    Likes Received:
    0
    Eventually I added a new MX record and rolled out postfix on a vm, where I could set up forwarding very painless. Needless to say, shortly after everything was done, the power came back :/

    Thank you for the help again.
     

Want to reply or ask your own question?

It only takes a minute to sign up (and it's free!). Click the orange sign up button to choose a username and then you can ask your own questions on the forum.
Loading...