Postfix Not Sending Mail

I added 3 domains to my Virtualmin Pro server last week, and all was working fine. I don't send/receive much email to/from those domains, so I didn't notice this issue until today when I added two new top-level virtual servers. The email message I have set up to be sent to new clients was not sent. So, I restarted Postfix, and sent a test message to my Virtualmin Pro server. I got an error in my mail client (the same error message as in the log below) and the message could not be sent. Receiving mail appears to be working fine. The following appears in /var/log/mail.log:

Note that X's mean that I've omitted hostname/IP address information.

Feb 13 16:14:20 server1 postfix/smtpd[11667]: connect from xxxx-xxxxxx-x-x-xxxxxxx.xxxx.cable.virginmedia.com[xx.xxx.xxx.xxx]
Feb 13 16:14:20 server1 postfix/smtpd[11667]: NOQUEUE: reject: RCPT from xxxx-xxxxxx-x-x-xxxxxxx.xxxx.cable.virginmedia.com[xx.xxx.xxx.xxx]: 550 5.1.1 <james@xxxxxxxxxxxx.com>: Recipient address rejected: User unknown in virtual alias table; from=<james.scholes@xxxxxxxx.net> to=<james@xxxxxxxxxxxx.com> proto=ESMTP helo=<[192.168.0.103]>
Feb 13 16:14:26 server1 postfix/smtpd[11667]: disconnect from xxxx-xxxxxx-x-x-xxxxxxx.xxxx.cable.virginmedia.com[xx.xxx.xxx.xxx]

I have not changed any configuration, either from the terminal or from Virtualmin Pro's interface, so am at a loss as to why this error would suddenly occur.

Status: 
Active

Comments

Howdy -- what output do you get if you run the command "hostname" on the command line of your server?

Whatever that output is, that exact name should show up next to your public IP in /etc/hosts, as well as on the "mydestination" line of /etc/postfix/main.cf.

If you make any changes there, be sure to restart Postfix with "/etc/init.d/postfix restart".

Let us know if that does the trick!

root@server1:~# hostname
server1
root@server1:~# cat /etc/postfix/main.cf | grep mydestination
mydestination = server1.xxxxxxxx.net, localhost.xxxxxxxx.net, , localhost
root@server1:~# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
xxx.xx.xxx.xxx server1.xxxxxxxx.net server1

# The following lines are desirable for IPv6 capable hosts
...

As I say, I haven't modified any of these settings since mail was working. My hostname has remained the same, and I haven't edited /etc/postfix/main.cf or /etc/hosts at all.

Okay, I suspect the issue is that your hostname isn't an FQDN. I'm not sure how that changed, but we can fix it :-)

First, run this command:

hostname server1.xxxxxxxx.net

That will set your hostname to the correct FQDN that your configs expect.

Then, edit /etc/hostname, and make sure the full "server1.xxxxxxxx.net" is set in there.

I always set my servers up witha short hostname (i.e. server1) and an FQDN. That hasn't changed since mail was working. The FQDN is now set, and hostname returns "server1.xxxxxxxx.net". I restarted postfix (/etc/init.d/postfix restart), but sendng mail still fails with the same error.

The hostname in the config files being out of sync is a common cause of what you're seeing. It's possible something like that could have changed after a reboot, but if that were the case, resetting the hostname should have corrected that.

If you go into System Settings -> Re-Check Config, does it see any problems with your setup?

No. It reports that all is fine. That was one of the first things I tried, after restarting Postfix:

The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active ..
Mail server Postfix is installed and configured.
Apache is installed.
Webalizer is installed.
Apache is configured to host SSL websites.
MySQL is installed and running.
ProFTPd is installed.
Logrotate is installed.
SpamAssassin and Procmail are installed and configured for use.
ClamAV is installed and assumed to be running.
The System and Server Status module is installed and checking on schedule.
Plugin AWstats reporting is installed OK.
Plugin DAV Login is installed OK.
Plugin Mailman is installed OK.
Plugin Protected web directories is installed OK.
Using network interface eth0 for virtual IPs.
IPv6 addresses are available, using interface eth0.
Default IP address for virtual servers is 178.79.143.113.
Default IP address is set to 178.79.143.113, which matches the detected external address.
Both user and group quotas are enabled for home and email directories.
All commands needed to create and restore backups are installed.
Resource limits are supported and configured correctly.
The selected package management and update systems are installed OK.
.. your system is ready for use by Virtualmin.

Okay, that's good that it doesn't see any problems, but that doesn't help getting your email working :-)

I'm not sure what's causing those issues you're seeing... would it be possible for me to log into your server to do some troubleshooting?

What I would need are root login details, as well as an email account that's not working that I can use for sending some test emails to.

You can either install the Virtualmin Support module, and enable Remote Support, or you can email your root login details to eric@virtualmin.com.

I received your email today, thanks!

You had mentioned receiving this error:

550 5.1.1 <james@xxxxxxxxxxxx.com>: Recipient address rejected: User unknown in virtual alias table; from=<james.scholes@xxxxxxxx.net> to=<james@xxxxxxxxxxxx.com>

Based on that error, it looks like you were trying to send an email from james.scholes@xxxxxxxx.net and to james@xxxxxxxxxxxx.com.

Does that sound correct?

Here's the problem I'm running into -- using your james.scholes@xxxxxxxx.net account, I seem to be able to send and receive emails just fine. I sent an email to my own account, to james.scholes@xxxxxxxx.net, and to the jamesscholes@xxxxxxxxxxxx.com account on your other Virtual Server. Those all worked well, and were received.

Here's what I do see though -- if you tried to send an email to james@xxxxxxxxxxxx.com, it doesn't look like that address exists.

That is, I do see a jamesscholes@xxxxxxxxxxxx.com, but no james@xxxxxxxxxxxx.com.

If it was indeed james@ that you were trying to email, it looks like you may need to setup that alias within that Virtual Server.

I think I know what's going on. I should've explained that my mail for jxxxxxxxxxxs.com is currently hosted on a shared web hosting account that I've had for quite a while. I had planned to update the NS records to point at my Virtualmin Pro server yesterday, before I begun having these email issues. I guess that's what's going on; Postfix notices that jxxxxxxxxxxs.com is in it's domain list, so tries to send email to it locally, but of course, the required aliases/users don't exist yet. In other words, Postfix is sending mail locally instead of over the internet to the current mail servers defined in my MX records. I feel like an idiot now for not checking any other addresses; running virtualmin test-smtp --to something@gmail.com for example works fine. I didn't assume that Postfix would try to deliver mail locally to domains set up on the same system.

Ah, that would explain it!

Actually, there may be two gotchas you're running into.

First, since Postfix has been configured to locally delivery all email for that domain -- anytime it receives an email destined for that domain, it will attempt to deliver it. It doesn't look at the MX records in the DNS, since it was configured to handle email for that domain.

You could get around that particular problem by unchecking the "Mail for Domain" feature in Edit Virtual Server.

However, even if you did that -- since DNS is enabled for that domain, the MX record on your server would still point locally. So it would still try to deliver the messages to Postfix on your server.

So the second thing you'd need to do is either change the MX record on your server to point to your shared hosting provider, or just disable the "DNS Domain" feature until that domain is live on your server.

Or, if you're planning on moving that domain over soon, you can hold off on all that, as it won't matter once your domain is live on your server.

-Eric