# qmail + vpopmail - local mail delivery failing [SOLVED]

## dfelicia

I'll preface this post by saying I'm not an experienced mail admin; this setup is my first, so be gentle.   :Smile: 

I set up qmail per the doc.

```

mail-mta/netqmail-1.05-r8  USE="qmail-spp ssl -gencertdaily -highvolume -mailwrapper -noauthcram -vanilla"

```

My hostname is not the same as my domain name, though the IP is the same.  (DNS is correctly set up - A records exist for the hostname and domain.  MX record points to mail.example.com, and reverse record for IP is example.com)

So after installing netqmail, I ran emerge --config for it and it populated /var/qmail/control/me,locals,domain,plusdomain,rcpthosts with output of hostname --fqdn.  I manually changed all the files to use example.com, instead.

At this point, I fired up qmail-smtpd and qmail-send, and everything worked as expected.  I could send and receive mail.

After feeling confident that qmail was working properly, I installed vpopmail.

```

net-mail/vpopmail-5.4.20  USE="mysql -clearpasswd -ipalias -maildrop"

```

I ran "vadddomain example.com" and "vadduser jdoe".  I changed conf-smtpd by adding:

```

QMAIL_SMTP_CHECKPASSWORD="/var/vpopmail/bin/vchkpw"

```

After that, I restart qmail and tested that mail to jdoe@example.com was working.

At this point local mail delivery has stopped working.  If I add example.com to /var/qmail/control/locals it starts working, again, but the vpopmail doesn't work.  How can I make qmail deliver mail to local users (identified in /etc/passwd) and vpopmail users, too?

Relevant files, with actual hostname and domainname changed:

```

# hostname --fqdn

fakename.foo.bar.com

# pwd

/var/qmail/control

# cat me

example.com

# cat defaultdomain 

example.com

# cat plusdomain 

example.com

# cat rcpthosts

example.com

# cat locals

# cat virtualdomains

example.com:example.com

```

Last edited by dfelicia on Sat May 17, 2008 7:34 pm; edited 1 time in total

----------

## dfelicia

Well, I've figured out that if /var/qmail/control/me,defaultdomain,plusdomain have the same value as the virtual domain I set up with vpopmail, local mail delivery won't work.

If I put my hostname in the qmail control files, things improve, except:  1) mail sent from outside to localaccount@example.com gets bounced, 2) mail sent directly from the box to the outside gets rejected by many recipients b/c domain in header doesn't match domain in MX record.

Maybe what I'm trying do do isn't possible on a one machine/one IP address setup?

----------

## quart

What is it exactly you want? Do you want mail delivered to both virtual accounts and to local accounts? In that case, you could setup an account in vpopmail, and then forward the mail from these accounts to local accounts (for which you take your machine's FQDN). So email going to user@example.com is then forwarded to user@your.server.fqdn.tld which are local accounts.

----------

## dfelicia

Figured out my problem...

With vpopmail installed, /var/qmail/control/me cannot contain the same name as a vpopmail virtual domain (well, it can, but then local mail delivery won't work).  In my case, I had example.com in /var/qmail/control/me and had also named my virtual domain example.com.

Solution was simply to add an A record (a CNAME would've worked just as well, I guess) for my domain, then put that in me, locals, etc.  For kicks, though unneeded, I also renamed my host to match my new A record.  (I could've just as easily set MAILHOST in /etc/profile or the like.)

I had tried this before, as mentioned above, but was using a hostname issued by my VPS provider.  The VPS provided domain has no MX record to match my IP, causing ISPs to reject my mail.  (i.e. I was using a hostname like fakename.foo.bar.com in /var/qmail/control/me, etc.)

Anyway, now I have:

```

$ cd /var/qmail/control/

$ cat me

charon.example.com

$ cat defaultdomain

example.com

$ cat plusdomain

example.com

$ cat locals

charon.example.com

$ cat rcpthosts

example.com

charon.example.com

$ cat virtualdomains

example.com:example.com

```

So now local mail delivery works as it always did, and vpopmail is working for remote mail.

----------

