intermittent hang on "postfix stop"; doesn't return "terminating on signal"

2010-10-15 Thread Scott Brown
Hello,

I'm stuck with a problem where postfix is hanging sometimes when issuing a 
"postfix stop" command.  In my configuration, I have two domains I'm relaying 
mail for with postfix.  The lists of email addresses are in these virtual 
files, 
defined with this line in main.cf:
virtual_alias_maps = 
hash:$config_directory/usermanaged/virtual.domain1.com,hash:$config_directory/usermanaged/virtual.domain2.com


I have a script called update-postfix.pl that runs every half an hour which 
shuts down postfix, runs postmap on the virtual alias files, and then restarts 
postfix.  Most of the time, the script runs without any problems.  Actually, 
this configuration was running on a different server previously with no 
problems 
at all.  Because the old server was too slow, I set up a new postfix 
installation on a new server, and it's under the new setup that I'm running 
into 
this intermitent hanging problem.

Usually, when the update-postfix.pl script runs, it tells Postfix to shut down 
and we get a logged message that says "postfix/postfix-script: stopping the 
Postfix mail system".  Right after that, postfix responds with something like 
"postfix/master[11211]: terminating on signal 15"

However, sometimes (once every day or so), the script runs and we get the first 
message "postfix/postfix-script: stopping the Postfix mail system", but then 
postfix does not respond to it and keeps running for a while, until it sees the 
virtual.domain2.com.db was updated, at which point it logs 
"postfix/trivial-rewrite[16529]: table 
hash:/etc/postfix/usermanaged/virtual.domain2.com(0,lock|fold_fix) has changed 
-- restarting", and then after that, it appears to be hung.

My first thought was that maybe postfix didn't have enough of an opportunity to 
shut itself down before the .db was updated by the postmap command.  So I put 
in 
a sleep 60 right after the postfix stop command.  Even though when the stop 
command works, we see the "terminating on signal" response almost instantly. 
 Since the 60 seconds didn't work, I increased to 2 minutes, but that also 
didn't help.

I found a forum post (http://www.howtoforge.com/forums/showthread.php?t=15898) 
where someone had a somewhat similar problem.  Someone suggested running 
"newaliases".  So I tried deleting both virtual.domain2.com.db and 
virtual.domain1.com.db, then ran "newaliases", manually ran postmap for domain2 
and domain1, and restarted postfix.  But even after those steps, the problem 
kept happening.

This most recent time it hung, I tried issuing another "service postfix stop", 
as well as a plain "postfix stop", but neither of those caused postfix to 
respond with "terminating on signal".  I checked the ps aux process list, and 
tried killing the postfix processes I saw.  Then tried restarting, and got the 
"already running" error.  So I checked ps aux again and noticed there were a 
bunch of processes being run by the postfix user that were tagged with 
.  I tried killing those processes but couldn't kill them.

Does anyone have any ideas on what could be wrong?

Thanks very much in advance for any suggestions!

Scott


Below is a snippet from maillog showing what happens when it hangs.  You can 
see 
that at 23:30:02, the update-postfix.pl script kicks in and tries to stop 
postfix.  It doesn't succeed, and one minute later, Postfix sees the .db was 
updated and tries to restart.  Shortly after that, the update script tries to 
restart postfix but fails because it's already running.  Then postfix stays in 
a 
hung state, not accepting any incoming connections.  Half an hour later, the 
cron job runs again but fails to do anything because postfix is hung.

Oct  9 23:30:02 myserver postfix/postfix-script: stopping the Postfix mail 
system
Oct  9 23:31:04 myserver postfix/trivial-rewrite[16529]: table 
hash:/etc/postfix/usermanaged/virtual.domain2.com(0,lock|fold_fix) has changed 
-- 
restarting
Oct  9 23:31:14 myserver postfix/postfix-script: fatal: the Postfix mail system 
is 
already running
Oct  9 23:32:44 myserver postfix/anvil[16528]: statistics: max connection rate 
1/60s for 
(smtp:110.36.0.252) at Oct  9 23:29:03
Oct  9 23:32:44 myserver postfix/anvil[16528]: statistics: max connection count 
1 for 
(smtp:110.36.0.252) at Oct  9 23:29:03
Oct  9 23:32:44 myserver postfix/anvil[16528]: statistics: max cache size 2 at 
Oct  9 
23:29:23
Oct 10 00:00:02 myserver postfix/postfix-script: stopping the Postfix mail 
system
Oct 10 00:01:13 myserver postfix/postfix-script: fatal: the Postfix mail system 
is 
already running

update-postfix.pl:
-

#!/usr/bin/perl
$|=1;


my $dir= "/var";

my @fulldfinfo = `df $dir`;
#/dev/da0s1f33851580 28087462 305599290%/var

my ($dfdevice,$total,$used,$avail,$pct,$dfmount)=split /[\b\t 
]+/,$fulldfinfo[1];

print "space available=$avail\nspace used=$used";
if ($avail > 0) {

open(SH, "|/bin/sh");
print SH <<"EOM";
umask 022
cd /etc/postfix
/sbin/service postfix stop
sleep 120
/usr/sbin/

Re: intermittent hang on "postfix stop"; doesn't return "terminating on signal"

2010-10-15 Thread Scott Brown
Wietse,
Awesome response - thank you very much!

You have really demystified a lot of what's going on for me.

I see what you're saying about there being better ways to update the Berkeley 
.db files.  It does seem like an upgrade to a less disruptive approach would be 
in order.

But at the same time, whatever is causing this hanging is probably an 
underlying 
issue that I should resolve as it could pop up elsewhere.  I will take your 
advice and run the gnu debugger next time I get a hang, and report the results. 
 I'd like to get to the bottom of this problem, but then I agree it would make 
sense to come up with a better .db update scheme.

Thanks again
Scott


- Original Message 
From: Wietse Venema 
To: Postfix users 
Sent: Fri, October 15, 2010 10:10:20 AM
Subject: Re: intermittent hang on "postfix stop"; doesn't return "terminating 
on 
signal"

Scott Brown:
> Usually, when the update-postfix.pl script runs, it tells Postfix to shut 
> down 

> and we get a logged message that says "postfix/postfix-script: stopping the 
> Postfix mail system".  Right after that, postfix responds with something like 
> "postfix/master[11211]: terminating on signal 15"
> 
> However, sometimes (once every day or so), the script runs and we get the 
> first 
>
> message "postfix/postfix-script: stopping the Postfix mail system", but then 
> postfix does not respond to it and keeps running for a while, until it sees 
> the 
>
> virtual.domain2.com.db was updated, at which point it logs 
> "postfix/trivial-rewrite[16529]: table 
> hash:/etc/postfix/usermanaged/virtual.domain2.com(0,lock|fold_fix) has changed
> -- restarting", and then after that, it appears to be hung.

You mean, the master did not terminate trivial-rewrite and
then itself, as it is normally does.

When you say "postfix stop", the postfix-script file sends a SIGTERM
signal to the process ID in $queue_directory/pid/master.pid.

There are a number of possible explanations:

1) The master.pid file is bad - it contains a different PID than
that of the running master daemon, and therefore "postfix stop"
does not send. In that case, Postfix keeps handling mail, but that
is not what you observe, because trivial-rewrite is still running.

2) The master.pid file is good, and the master is stuck 
after it receives the SIGTERM signal.

The code in the master's sigterm handler is trivially simple. When
I omit the comments (which contain more text that the code itself):

 1  static void master_sigdeath(int sig)
 2  {
 3  const char *myname = "master_sigdeath";
 4  struct sigaction action;
 5  pid_t   pid = getpid();
 6  
 7  killme_after(5);
 8  
 9  sigemptyset(&action.sa_mask);
10  action.sa_flags = 0;
11  action.sa_handler = SIG_IGN;
12  if (sigaction(SIGTERM, &action, (struct sigaction *) 0) < 0)
13  msg_fatal("%s: sigaction: %m", myname);
14  if (kill(-pid, SIGTERM) < 0)
15  msg_fatal("%s: kill process group: %m", myname);
16  msg_info("terminating on signal %d", sig);
17  ...

(The killme_after() function is a workaround for Linux that 
sets up a time bomb to terminate the master in 5 seconds).

Line 14 terminates all master's child processes including
trivial-rewrite.  Apparently this line did not not execute, so I
wonder where the execution has stopped.

Next time, can you do:

gdb -p pid-of-master-daemon
...garbage...
(gdb) bt

And report the result.

I would also like to mention that "postfix stop" is a very disruptive
way to update a table. Instead, consider doing a "safe update" of
the Berkeley DB map as described in:

http://www.postfix.org/DATABASE_README.html#safe_db

This updates the file without overwriting it.

Wietse



  


Re: intermittent hang on "postfix stop"; doesn't return "terminating on signal"

2010-10-15 Thread Scott Brown
Wietse,
Thanks again for your help.  Also thanks to Viktor for his thoughts about the 
version.
I checked and I see I do in fact have an old version of postfix installed, 
which 
is 2.3.3.  This is surprising because I installed it using "yum install 
postfix", which I had assumed would install the most recent version.  

Anyway, what would be the best way to upgrade?  I see from some Google searches 
that there can be issues if you try to do a yum install while postfix is 
running.  Could I just stop postfix and do "yum install postfix-2.7.1"?  Would 
I 
need to uninstall the current postfix first then re-install the correct version?

I am on centos:
Linux version 2.6.18-194.11.4.el5xen (mockbu...@builder10.centos.org) (gcc 
version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Sep 21 05:40:24 EDT 2010


Scott


- Original Message 
From: Wietse Venema 
To: Postfix users 
Sent: Fri, October 15, 2010 11:25:47 AM
Subject: Re: intermittent hang on "postfix stop"; doesn't return "terminating 
on 
signal"

Scott Brown:
> Wietse,
> Awesome response - thank you very much!
> 
> You have really demystified a lot of what's going on for me.
> 
> I see what you're saying about there being better ways to update the Berkeley 
> .db files.  It does seem like an upgrade to a less disruptive approach would 
> be 
>
> in order.
> 
> But at the same time, whatever is causing this hanging is probably an 
>underlying 
>
> issue that I should resolve as it could pop up elsewhere.  I will take your 
> advice and run the gnu debugger next time I get a hang, and report the 
> results. 
>
>  I'd like to get to the bottom of this problem, but then I agree it would 
> make 

> sense to come up with a better .db update scheme.
> 
> Thanks again
> Scott

As Victor mentioned, we put in workarounds in Postfix 2.4 for
hanging master processes while logging "terminating on signal".

At the time, master logged "terminating on signal" BEFORE terminating
its child processes (including trivial-rewrite).  This is consistent
with the behavior that you observe:  no "terminating on signal"
message and no child process termination.

I suspect that you're running an older Postfix version, in which
case the problem will not be fixed. The oldest supported release
is Postfix 2.4.

Wietse



  


Re: intermittent hang on "postfix stop"; doesn't return "terminating on signal"

2010-10-15 Thread Scott Brown
Thanks Viktor!  For anyone who runs into the same/similar problem: it seems no 
more up-to-date yum package is available for CentOS.  I found some pre-compiled 
packages for CentOS 5 at http://www.linuxmail.info/postfix-rpm-packages/.  I 
was 
able to do an rpm install of the 2.5.1 postfix package, which automatically 
upgraded the existing installation.

Scott


- Original Message 
From: Victor Duchovni 
To: postfix-users@postfix.org
Sent: Fri, October 15, 2010 12:03:33 PM
Subject: Re: intermittent hang on "postfix stop"; doesn't return "terminating 
on 
signal"

On Fri, Oct 15, 2010 at 08:57:48AM -0700, Scott Brown wrote:

> Anyway, what would be the best way to upgrade?

Read the Postfix release notes. These will highlight any potential
compatibility issues and major changes.

When upgrading from a release this old, yes you do need to stop Postfix
first.

Make sure that your binary package installer correctly upgrades
the main.cf and master.cf files via "postfix set-permissions
upgrade-configuration". Do not undo this by re-installing original
main.cf/master.cf files from before the upgrade.

For other help on Linux package management, this is not the right forum.

-- 
Viktor.



  


Installing postfix with mysql

2012-03-07 Thread Scott Brown
Hello,
I am trying to install Postfix with mysql on CentOS 6.0.

I am trying to follow the instructions 
at http://www.postfix.org/MYSQL_README.html

I downloaded the mysql libraries and source code.

The libmysql was extracted 
to /usr/local/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit

So from the postfix-2.9.1 directory, I ran:
make -f Makefile.init makefiles \
    'CCARGS=-DHAS_MYSQL
-I/usr/local/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/include' \
    'AUXLIBS=-L/usr/local/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib
-lmysqlclient -lz -lm'

Then ran the make command

When I try to run make install, I get this error:
bin/postconf: error while loading shared
libraries: libmysql.so.16: cannot open shared object file: No such file or
directory 

I found an article online 
(http://webhostingneeds.com/Error_while_loading_shared_libraries:_libmysqlclient.so.16)
  that suggests the /usr/lib/mysql path needs to be added to ld.so.conf, so I 
did that.  I also created a symlink called libmysql.so.16 in that folder which 
points to libmysqlclient.so.16 (I did not actually have a file called 
libmysql.so.16).

I am getting the impression libmysql is different from libmysqlclient.  But I 
don't see where I can get this "libmysql" package.  I tried "yum install 
libmysql" but it said there was no package available.

Any help would be greatly appreciated!

Thank you

Scott Brown


Re: Installing postfix with mysql

2012-03-07 Thread Scott Brown
I want to use MySQL to manage the virtual table within Postfix. So it's not 
that I want to just have MySQL and Postfix on the server as separate 
applications.  I want the MySQL-enhanced version of Postfix.


- Original Message -
From: Reindl Harald 
To: postfix-users@postfix.org
Cc: 
Sent: Wednesday, March 7, 2012 6:55 PM
Subject: Re: Installing postfix with mysql



Am 08.03.2012 00:46, schrieb Scott Brown scottwb...@yahoo.com:
> Hello,
> I am trying to install Postfix with mysql on CentOS 6.0.
> I am trying to follow the instructions at 
> http://www.postfix.org/MYSQL_README.html
> I downloaded the mysql libraries and source code.

why?

"yum install mysql-devel"

> The libmysql was extracted to 
> /usr/local/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit

AFAIK this is not mysql-devel

> When I try to run make install, I get this error:
> bin/postconf: error while loading shared
> libraries: libmysql.so.16: cannot open shared object file: No such file or
> directory 

use as much system-packages as you can in as much default locations as possible!


Re: Installing postfix with mysql

2012-03-12 Thread Scott Brown
That worked! Thank you very much!



 From: Mailinglist 
To: Scott Brown  
Cc: Reindl Harald ; "postfix-users@postfix.org" 
 
Sent: Wednesday, March 7, 2012 7:17 PM
Subject: Re: Installing postfix with mysql
 
CentOS Plus repo already has the postfix-SQL rpm. Go into 
/etc/yum.repo/CentOS.repo file and exclude postfix under Base and Updates. Then 
run yum --enablerepo=centosplus install postfix - this will install the version 
you need without having to compile. 

Regards

On Mar 7, 2012, at 6:59 PM, Scott Brown  wrote:

> I want to use MySQL to manage the virtual table within Postfix. So it's not 
> that I want to just have MySQL and Postfix on the server as separate 
> applications.  I want the MySQL-enhanced version of Postfix.
> 
> 
> - Original Message -
> From: Reindl Harald 
> To: postfix-users@postfix.org
> Cc: 
> Sent: Wednesday, March 7, 2012 6:55 PM
> Subject: Re: Installing postfix with mysql
> 
> 
> 
> Am 08.03.2012 00:46, schrieb Scott Brown scottwb...@yahoo.com:
>> Hello,
>> I am trying to install Postfix with mysql on CentOS 6.0.
>> I am trying to follow the instructions at 
>> http://www.postfix.org/MYSQL_README.html
>> I downloaded the mysql libraries and source code.
> 
> why?
> 
> "yum install mysql-devel"
> 
>> The libmysql was extracted to 
>> /usr/local/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit
> 
> AFAIK this is not mysql-devel
> 
>> When I try to run make install, I get this error:
>> bin/postconf: error while loading shared
>> libraries: libmysql.so.16: cannot open shared object file: No such file or
>> directory 
> 
> use as much system-packages as you can in as much default locations as 
> possible!

separate log for amavisd-new

2012-05-04 Thread Scott Brown
Hello,
Instead of including the amavisd activity in the maillog, I want to have a 
separate log file.  I can't figure out how to get this working though.

For some reason, amavisd isn't writing to the log file that's defined in 
/etc/amavisd.conf

If I do a directory listing, the log still shows as 0 bytes:
ls -l amavis.log
-rwxrwxrwx 1 vscan vscan 0 Nov 30 09:39 amavis.log

when I initially set up the postfix/mysql/amavisd system, I created an empty 
amavis.log and changed the owner to the user amavis is running under:
chown vscan:vscan /var/log/amavis.log
chmod u=rw,g=rw,o=rw /var/log/amavis.log

Any idea what could be wrong?  Below are the relevant entries from amavisd.conf:
$log_level = 2;              # verbosity 0..5, -d
$log_recip_templ = undef;    # disable by-recipient level-0 log entries
$DO_SYSLOG = 0;              # log via syslogd (preferred)
$LOGFILE = "/var/log/amavis.log";
$log_templ = '[? %#V |[? %#F |[?%#D|Not-Delivered|Passed]|BANNED name/type 
(%F)]|INFECTED (%V)], <%o> -> [<%R>|,][? %i ||, quarantine %i], Message-ID: %m, 
Hits: %c';
#$syslog_facility = 'local7';   # Syslog facility as a string
           # e.g.: mail, daemon, user, local0, ... local7
#$syslog_priority = 'debug';  # Syslog base (minimal) priority as a string,
           # choose from: emerg, alert, crit, err, warning, notice, info, debug


Thank you

Scott Brown


postfix thinks mysql managed email address is remote

2012-08-07 Thread Scott Brown
6]: rewrite_clnt: local: 
sbr...@domainaftermysql.com -> sbr...@domainaftermysql.com
Aug  7 17:50:03 miltermatic postfix/smtpd[15246]: send attr address = 
sbr...@domainaftermysql.com
Aug  7 17:50:03 miltermatic postfix/smtpd[15246]: input attribute value: 
sbr...@domainaftermysql.com
Aug  7 17:50:03 miltermatic postfix/smtpd[15246]: resolve_clnt: `' -> 
`sbr...@domainaftermysql.com' -> transp=`smtp' host=`67.22.105.2' 
rcpt=`sbr...@domainaftermysql.com' flags= class=default
Aug  7 17:50:03 miltermatic postfix/smtpd[15246]: ctable_locate: install entry 
key sbr...@domainaftermysql.com
Aug  7 17:50:03 miltermatic postfix/smtpd[15246]: extract_addr: in: 
, result: sbr...@domainaftermysql.com
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: check_mail_access: 
sbr...@domainaftermysql.com
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: ctable_locate: move existing 
entry key sbr...@domainaftermysql.com
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: check_access: 
sbr...@domainaftermysql.com
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: reject_unauth_destination: 
sbr...@domainaftermysql.com
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: permit_auth_destination: 
sbr...@domainaftermysql.com
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: ctable_locate: leave existing 
entry key sbr...@domainaftermysql.com
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: NOQUEUE: reject: RCPT from 
mail-qc0-f170.google.com[209.85.216.170]: 554 5.7.1 
: Relay access denied; from= 
to= proto=ESMTP helo=
Aug  7 17:50:04 miltermatic postfix/smtpd[15246]: > 
mail-qc0-f170.google.com[209.85.216.170]: 554 5.7.1 
: Relay access denied

I get "Relay access denied" if I try sending email to that domain from gmail.  
If I try sending email to that domain with a manual telnet smtp session to 
localhost port 25 on the machine postfix is running on, it goes through fine:
Aug  7 18:08:29 miltermatic postfix/smtpd[15246]: ctable_locate: purge entry 
key sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: < SERVER9678[127.0.0.1]: rcpt 
to: sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: extract_addr: input: 
sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: smtpd_check_addr: 
addr=sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: send attr address = 
sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: input attribute value: 
sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: rewrite_clnt: local: 
sbr...@domainaftermysql.com -> sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: send attr address = 
sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: input attribute value: 
sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: resolve_clnt: `' -> 
`sbr...@domainaftermysql.com' -> transp=`smtp' host=`67.22.105.2' 
rcpt=`sbr...@domainaftermysql.com' flags= class=default
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: ctable_locate: install entry 
key sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: extract_addr: in: 
sbr...@domainaftermysql.com, result: sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: check_mail_access: 
sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: ctable_locate: move existing 
entry key sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: check_access: 
sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: ctable_locate: leave existing 
entry key sbr...@domainaftermysql.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: maps_find: 
recipient_canonical_maps: sbr...@domainaftermysql.com: not found
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: mail_addr_find: 
sbr...@domainaftermysql.com -> (not found)
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: maps_find: canonical_maps: 
sbr...@domainaftermysql.com: not found
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: mail_addr_find: 
sbr...@domainaftermysql.com -> (not found)
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: maps_find: 
virtual_alias_maps: mysql:/etc/postfix/mysql-virtual.cf(0,lock|fold_fix): 
sbr...@domainaftermysql.com = scottwb...@yahoo.com
Aug  7 18:17:51 miltermatic postfix/smtpd[20072]: mail_addr_find: 
sbr...@domainaftermysql.com -> scottwb...@yahoo.com
Aug  7 18:18:11 miltermatic postfix/smtp[19830]: E8FBA14A8066: 
to=, orig_to=, 
relay=127.0.0.1[127.0.0.1]:10024, delay=29, delays=29/0/0/0.3, dsn=2.0.0, 
status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued 
as CACAD14A805F)


Any help would be greatly appreciated!

Thank you

Scott Brown


Re: postfix thinks mysql managed email address is remote

2012-08-08 Thread Scott Brown
Rob,
thank you very much for the pointers on reposting.

I turned off the -v setting on smtpd

The old virtual domain is resumearrow.com.  The new, mysql-managed domain, is 
parallelemail.com

If I run a postmap -q on my email address under both domains, the results are 
the same:
[root@miltermatic log]# postmap -q sbr...@resumearrow.com 
mysql:/etc/postfix/mysql-virtual.cf
scottwb...@yahoo.com
[root@miltermatic log]# postmap -q sbr...@parallelemail.com 
mysql:/etc/postfix/mysql-virtual.cf
scottwb...@yahoo.com

Because postfix rejects the session at the RCPT command, I don't believe any 
further details of the session are available for the parallelemail domain:
[root@miltermatic log]# grep "sbr...@parallelemail.com" maillog
Aug  8 10:33:21 miltermatic postfix/smtpd[10117]: NOQUEUE: reject: RCPT from 
mail-qc0-f170.google.com[209.85.216.170]: 554 5.7.1 : 
Relay access denied; from= to= 
proto=ESMTP helo=

Postfix did assign a message identifier to the email to resumearrow.com, so I 
can provide more, non-verbose, session details on that:
[root@miltermatic log]# grep "sbr...@resumearrow.com" maillog
Aug  8 10:33:07 miltermatic postfix/smtp[10081]: 971C814A805F: 
to=, orig_to=, 
relay=127.0.0.1[127.0.0.1]:10024, delay=5.3, delays=0.58/0/0/4.8, dsn=2.0.0, 
status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued 
as 6919414A8066)
[root@miltermatic log]# grep "971C814A805F" maillog
Aug  8 10:33:02 miltermatic postfix/smtpd[10119]: 971C814A805F: 
client=mail-qa0-f49.google.com[209.85.216.49]
Aug  8 10:33:02 miltermatic postfix/cleanup[10060]: 971C814A805F: 
message-id=
Aug  8 10:33:02 miltermatic postfix/qmgr[10053]: 971C814A805F: 
from=, size=5732, nrcpt=1 (queue active)
Aug  8 10:33:07 miltermatic postfix/smtp[10081]: 971C814A805F: 
to=, orig_to=, 
relay=127.0.0.1[127.0.0.1]:10024, delay=5.3, delays=0.58/0/0/4.8, dsn=2.0.0, 
status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued 
as 6919414A8066)
Aug  8 10:33:07 miltermatic postfix/qmgr[10053]: 971C814A805F: removed

Here's the postconf -n output:
[root@miltermatic log]# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
body_checks = regexp:$config_directory/usermanaged/body_checks
command_directory = /usr/sbin
config_directory = /etc/postfix
content_filter = amavisd-new:[127.0.0.1]:10024
daemon_directory = /usr/libexec/postfix
debug_peer_level = 3
default_process_limit = 30
header_checks = regexp:$config_directory/usermanaged/header_checks
html_directory = /usr/share/doc/postfix-2.5.1-documentation/html
inet_interfaces = $myhostname, localhost
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydomain = miltermatic.hiresites.com
myhostname = miltermatic.hiresites.com
mynetworks = 67.22.105.2 67.22.105.3 127.0.0.1 67.22.101.154 10.10.17.56
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.5.1-documentation/readme
relayhost = 67.22.105.2
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_connection_cache_destinations = 
smtp_connection_cache_on_demand = no
smtpd_banner = $myhostname ESMTP MilterMatician (0.1)
                                reject_unknown_recipient_domain
smtpd_sereject_rbl_client relays.mail-abuse.org.org, 
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf

Thanks again - I look forward to your ideas on how to troubleshoot further

Scott


- Original Message -
From: /dev/rob0 
To: postfix-users@postfix.org
Cc: 
Sent: Tuesday, August 7, 2012 6:50 PM
Subject: Re: postfix thinks mysql managed email address is remote

On Tue, Aug 07, 2012 at 03:28:45PM -0700, Scott Brown wrote:
> I recently switched from using flat virtual files to using mysql
> to manage a virtual table.

http://www.postfix.org/DATABASE_README.html#preparing is worth a 
read.

> Email addresses that were set up prior to the switchover can be 
> reached.  But emails set up afterwards can't.

postmap -q new@address mysql:/path/to/your/query

> I added verbose logging to the smtp processes by adding the -v 
> parameter in master.cf

It looks like you added it to smtpd, not smtp. Probably was not 
necessary.

> With old email addresses set up prior to mysql, the resolve_clnt 
> function seems to recognize that the domain is local, even though 
> it doesn't initially see the email address in the virtual alias 
> table (not sure why)

Your post should have included "postconf -n" also. This would have 
been more useful than verbose logs.

> With the new email addresses that are managed by mysql, 
> resolve_clnt doesn't seem to be looking up the email in the virtual 
> table.  Instead, it comes back with the host IP address -- this is 
> the relayhost value s

Re: postfix thinks mysql managed email address is remote

2012-08-08 Thread Scott Brown
Rob,
Thank you very much for your help.  It looks like the missing 
virtual_alias_domains was the problem.  

Scott


- Original Message -
From: /dev/rob0 
To: postfix-users@postfix.org
Cc: 
Sent: Wednesday, August 8, 2012 5:24 PM
Subject: Re: postfix thinks mysql managed email address is remote

On Wed, Aug 08, 2012 at 07:40:22AM -0700, Scott Brown wrote:
> The old virtual domain is resumearrow.com.  The new, mysql-managed 
> domain, is parallelemail.com
> 
> If I run a postmap -q on my email address under both domains, the 
> results are the same:
> [root@miltermatic log]# postmap -q sbr...@resumearrow.com 
> mysql:/etc/postfix/mysql-virtual.cf
> scottwb...@yahoo.com
> [root@miltermatic log]# postmap -q sbr...@parallelemail.com 
> mysql:/etc/postfix/mysql-virtual.cf
> scottwb...@yahoo.com

This is virtual_alias_maps. You don't show a setting below for 
virtual_alias_domains, and the default is "$virtual_alias_maps". So 
try this:

postmap -q resumearrow.com mysql:/etc/postfix/mysql-virtual.cf
postmap -q parallelemail.com mysql:/etc/postfix/mysql-virtual.cf

As I said, the domain lookup is failing. Therefore it is considered 
an unauthorized destination, and reject_unauth_destination blocks 
your mail.

http://www.postfix.org/ADDRESS_CLASS_README.html#virtual_alias_class
http://www.postfix.org/VIRTUAL_README.html#virtual_alias

BTW, same-envelope forwarding of mail to domains you do not control 
(yahoo.com) is likely to be troublesome. When you get and forward 
spam, they might flag you as a spam source.

> Because postfix rejects the session at the RCPT command, I don't 
> believe any further details of the session are available for the 
> parallelemail domain:
> [root@miltermatic log]# grep "sbr...@parallelemail.com" maillog
> Aug  8 10:33:21 miltermatic postfix/smtpd[10117]: NOQUEUE: reject: RCPT from 
> mail-qc0-f170.google.com[209.85.216.170]: 554 5.7.1 
> : Relay access denied; from= 
> to= proto=ESMTP helo=
> 
> Postfix did assign a message identifier to the email to 
> resumearrow.com, so I can provide more, non-verbose, session 
> details on that:
> [root@miltermatic log]# grep "sbr...@resumearrow.com" maillog
> Aug  8 10:33:07 miltermatic postfix/smtp[10081]: 971C814A805F: 
> to=, orig_to=, 
> relay=127.0.0.1[127.0.0.1]:10024, delay=5.3, delays=0.58/0/0/4.8, dsn=2.0.0, 
> status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued 
> as 6919414A8066)
> [root@miltermatic log]# grep "971C814A805F" maillog
> Aug  8 10:33:02 miltermatic postfix/smtpd[10119]: 971C814A805F: 
> client=mail-qa0-f49.google.com[209.85.216.49]
> Aug  8 10:33:02 miltermatic postfix/cleanup[10060]: 971C814A805F: 
> message-id=
> Aug  8 10:33:02 miltermatic postfix/qmgr[10053]: 971C814A805F: 
> from=, size=5732, nrcpt=1 (queue active)
> Aug  8 10:33:07 miltermatic postfix/smtp[10081]: 971C814A805F: 
> to=, orig_to=, 
> relay=127.0.0.1[127.0.0.1]:10024, delay=5.3, delays=0.58/0/0/4.8, dsn=2.0.0, 
> status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued 
> as 6919414A8066)
> Aug  8 10:33:07 miltermatic postfix/qmgr[10053]: 971C814A805F: removed
> 
> Here's the postconf -n output:
> [root@miltermatic log]# postconf -n
> alias_database = hash:/etc/aliases
> alias_maps = hash:/etc/aliases
> body_checks = regexp:$config_directory/usermanaged/body_checks
> command_directory = /usr/sbin
> config_directory = /etc/postfix
> content_filter = amavisd-new:[127.0.0.1]:10024
> daemon_directory = /usr/libexec/postfix
> debug_peer_level = 3
> default_process_limit = 30
> header_checks = regexp:$config_directory/usermanaged/header_checks
> html_directory = /usr/share/doc/postfix-2.5.1-documentation/html
> inet_interfaces = $myhostname, localhost
> mail_owner = postfix
> mailq_path = /usr/bin/mailq.postfix
> manpage_directory = /usr/share/man
> mydomain = miltermatic.hiresites.com
> myhostname = miltermatic.hiresites.com
> mynetworks = 67.22.105.2 67.22.105.3 127.0.0.1 67.22.101.154 10.10.17.56
> myorigin = $myhostname
> newaliases_path = /usr/bin/newaliases.postfix
> queue_directory = /var/spool/postfix
> readme_directory = /usr/share/doc/postfix-2.5.1-documentation/readme
> relayhost = 67.22.105.2

Enclose that in [] to inhibit MX lookup, which obviously won't find 
anything for "67.22.105.2". Also, having a relayhost in mynetworks 
might not always be a good idea. If that host thought mail should go 
back to you for some reason, you'd have a mail loop.

> sample_directory = /etc/postfix
> sendmail_path = /usr/sbin/sendmail.postfix
> setgid_group = postdrop
> smtp_connection_cache_destinations = 
> smtp_connection_cache_on_demand = no
> smtpd_banner = $myhostname ESMTP MilterMatician (0.1)
>