Mail works for user@host.domain but not for user@domain

I just took the plunge and got my first linode today. Yeah! :D

Got Karmic going with Apache and MySQL. I almost have Postfix working the way I want. Now, the last time I set up a mailserver was 1995. That was sendmail. Suffice to say, I am rusty. :?

Ok, so my domain is nebulocity.net and my linode hostname is is zathras.nebulocity.net. [1] I used the excellent Guide to setting up Dovecot and Postfix with MySQL. Whew! After I added a test account (support@nebulocity.net) in the mail.domains table, I also created a corresponding user on the system. [2] Now mail sent by user 'support' appears to come not from support@nebulocity.net but from support@zathras.nebulocity.net. Conversely, mail sent to support@zathras.nebulocity.net arrives in the 'support' mailbox but mail sent to support@nebulocity.net never shows up. :!:

I see nothing in /var/log/mail.log, which probably makes sense since this seems more likely to be an MTA issue than a POP issue. So I guess I should be looking at the dovecot logs… :?:

Anyway, if anyone just knows what I did "wrong" I would appreciate a pointer. I'm going to dig into the dovecot logs and docs tomorrow.

Thanks,

K Dog

[1] The A records for mail.nebulocity.net and www.nebulocity.net seem to have propagated. I have requested an A record for zathras.nebulocity.net, but I don't think it has propagated yet.

[2] This would be a good thing to add to the Guide.

7 Replies

* Update Start 2010-03-28 *

Ok, try this… Mail sent from joschmo@gmail.com to support.nebulocity.net does in fact get delivered! If as root I run 'mutt -f .' in the directory '/home/vmail/nebulocity.net/support/Maildir' I actually see the email. But if I log in as support (an ordinary user) then mutt gives me only the email which was addressed to support@zathras.nebulocity.net. Strange…starting to look more like a permissions issue.

  • Update End 2010-03-28 *

More information:

I cleaned out my logs and restarted all services.

Test user is 'support' and I am replacing my true registered domain name with 'mydomain.net' for the moment.

mysql> use mail
Database changed
mysql> select * from users;
+------------------------+---------------+
| email                  | password      |
+------------------------+---------------+
| support@mydomain.net   | PleaseNoHack  | 
+------------------------+---------------+

Now let's send to emails, back-to-back, from an outside account (gmail) to support, first as support@mydomain.net and then as support@hostname.mydomain.net.

Mail sent to 'support@mydomain.net' never shows up in mutt when I am logged in as 'support' – but mail sent to 'support@hostname.mydomain.net' does show up in mutt when I am logged in as 'support'.

So let's go to the logs! The first thing I notice is that /var/log/mail.info and /var/log/mail.log are identical. (I checked with diff(1).) Seems redundant?

Mar 28 15:10:09 hostname postfix/smtpd[3992]: connect from mail-pw0-f52.google.com[209.85.160.52]
Mar 28 15:10:09 hostname postfix/smtpd[3992]: A6A878772: client=mail-pw0-f52.google.com[209.85.160.52]
Mar 28 15:10:09 hostname postfix/cleanup[3997]: A6A878772: message-id= <ff7aef871003281510k4b0649bel6b0114f5ebfc400f@mail.gmail.com>Mar 28 15:10:09 hostname postfix/qmgr[2428]: A6A878772: from=<kblinode@gmail.com>, size=2021, nrcpt=1 (queue active)
Mar 28 15:10:09 hostname postfix/pipe[3998]: A6A878772: to=<support@mydomain.net>, relay=dovecot, delay=0.11, delays=0.08/0.01/0/0.02, dsn=2.0.0, status=sent (delivered via dovecot service)
Mar 28 15:10:09 hostname postfix/qmgr[2428]: A6A878772: removed
Mar 28 15:10:39 hostname postfix/smtpd[3992]: disconnect from mail-pw0-f52.google.com[209.85.160.52]
Mar 28 15:11:50 hostname postfix/smtpd[3992]: connect from mail-pw0-f49.google.com[209.85.160.49]
Mar 28 15:11:50 hostname postfix/smtpd[3992]: 2813A8772: client=mail-pw0-f49.google.com[209.85.160.49]
Mar 28 15:11:50 hostname postfix/cleanup[4173]: 2813A8772: message-id= <ff7aef871003281511j142d9337v29442c54de966708@mail.gmail.com>Mar 28 15:11:50 hostname postfix/qmgr[2428]: 2813A8772: from=<kblinode@gmail.com>, size=2076, nrcpt=1 (queue active)
Mar 28 15:11:50 hostname postfix/local[4174]: 2813A8772: to=<support@hostname.mydomain.net>, relay=local, delay=0.12, delays=0.11/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Mar 28 15:11:50 hostname postfix/qmgr[2428]: 2813A8772: removed
Mar 28 15:12:20 hostname postfix/smtpd[3992]: disconnect from mail-pw0-f49.google.com[209.85.160.49]</support@hostname.mydomain.net></kblinode@gmail.com></ff7aef871003281511j142d9337v29442c54de966708@mail.gmail.com></support@mydomain.net></kblinode@gmail.com></ff7aef871003281510k4b0649bel6b0114f5ebfc400f@mail.gmail.com> 

As you can see, mail sent to support@mydomain.net is being handled by dovecot, which I would expect based on the MySQL setup. The logs even say it was delivered, but I don't see it in mutt or for that matter in /var/mail/support.

But mail sent to support@hostname.mydomain.net is being handled by a local relay independent of dovecot and is appearing in /var/mail/support and therefore also in mutt.

I do notice the following lines in /etc/postfix/main.cf:

 ...
myhostname = hostname.mydomain.net
 ...
mydestination = hostname.mydomain.net, localhost, localhost.localdomain
...

where 'hostname' is the host name in /etc/hostname. Could that be the problem? I based that on ~~[http://library.linode.com/email/postfix/postfix-dovecot-mysql-ubuntu-9.10-karmic#configurepostfixtoworkwithmysql" target="blank">](http://library.linode.com/email/postfix … with_mysql">http://library.linode.com/email/postfix/postfix-dovecot-mysql-ubuntu-9.10-karmic#configurepostfixtoworkwith_mysql](.

I want all my mail handled by postfix+dovecot. Please help if you can.

Thanks.

AHA! Sure enough!

I edited /etc/postfix/main.cf as follows:

mydestination = hostname.mydomain.net, localhost, localhost.localdomain

becomes

#mydestination = hostname.mydomain.net, localhost, localhost.localdomain
mydestination = mydomain.net, localhost, localhost.localdomain

and lo! mail sent to 'support@mydomain.net' works like a champ!

I think maybe the Guide ~~[http://library.linode.com/email/postfix/postfix-dovecot-mysql-ubuntu-9.10-karmic" target="_blank">](http://library.linode.com/email/postfix … .10-karmic">http://library.linode.com/email/postfix/postfix-dovecot-mysql-ubuntu-9.10-karmic]( should be updated. I'm not saying it's wrong. I'm suggesting it might not be quite what most people expect or need.

I'm fairly new to this as well but here's a guess. I'm sure someone will jump in here and correct me if I'm way off base.

"support@mydomain.com" is a different user than "support". If you are using virtual users, you should always log in as the virtual user and not as a system (unix user) mailbox name.

For example, my username for SSH login might be "john" and there is a way to mail to the system user "john" but postfix/courier (in my case) don't know anything about "john". But it will know about john@mydomain.com if I set him up as a virtual user.

I'm not sure of the ramifications of not having the hostname in your mydestination line in main.cf. I used the postfix/courier/U9.10 tutorial and that one recommends hostname.mydomain.com as well. All my users are virtual and mydomain.com is in my virtual domains list (and I suppose subdomains of that as well?); mail to my postmaster@mydomain.com and postmaster@hostname.mydomain.com both show up in postmaster@mydomain.com's virtual mailbox.

My guess is that some tutorials are trying to thwart spam that is blindly sent to anyoneandeveryone@domain.com by setting up their systems to use blah@hostname.domain.com

Don't know how successful this is though.

Postfix will automatically reject mail for unknown users. From the Postfix readme:

Mail for all other addresses in example.com is rejected with the error message "User unknown".

I believe the answer to your original question lies here:

http://www.postfix.org/BASIC_CONFIGURAT … estination">http://www.postfix.org/BASICCONFIGURATIONREADME.html#mydestination

Note the very last line of that section:

Caution: in order to avoid mail delivery loops, you must list all hostnames of the machine, including $myhostname, and localhost.$mydomain.

By removing your hostname from the mydestination parameter, you may be introducing mail delivery problems later on (though the postfix documentation, I've found, is rather light on explanations/examples about documented warnings).

This is all very interesting.

The funny thing is… when I had the hostname included, dovecot was delivering only mail sent to the @hostname.domain form, and the @domain for was beng delivered but not by dovecot. Once I replaced hostname.domain with just domain in main.cf, both forms were delivered by dovecot. And -- so far -- nothing bad in my logs.

I also found the postfix docs rather light, but no worse than many others.

Thanks!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct