HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   HOWTO-Related Questions (http://www.howtoforge.com/forums/forumdisplay.php?f=2)
-   -   Postfix issues connecting to Mysql (http://www.howtoforge.com/forums/showthread.php?t=61546)

gregster 20th April 2013 20:02

Postfix issues connecting to Mysql
 
I had a perfect setup for years using the tutorial, but it seems after upgrade to Debian squeeze things have been pretty hit and miss. I'm currently having an issue where Postfix can't connect to MySQL (and yes I've gone through many threads with seemingly no success).

MySQL is running, and my MySQL based sites are online without issue. My mail.err file has this error, which seems to have happened to others:

Code:

postfix/trivial-rewrite[26396]: fatal: mysql:/etc/postfix/mysql-virtual-alias-maps.cf(0,lock|fold_fix): table lookup problem
The /etc/postfix/virtual files all look similar to:

Code:

user = mailuser
password = mypwd
hosts = localhost
dbname = mailserver
query = SELECT destination FROM view_aliases WHERE email='%s'

master.cf:

Code:

#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#              (yes)  (yes)  (yes)  (never) (100)
# ==========================================================================
72.232.180.227:25      inet  n      -      -      -      -      smtpd
72.232.180.227:587      inet  n      -      -      -      -      smtpd
#above should be ip:25 or :587
#submission inet n      -      -      -      -      smtpd
#  -o smtpd_enforce_tls=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#smtps    inet  n      -      -      -      -      smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#628      inet  n      -      -      -      -      qmqpd
pickup    fifo  n      -      -      60      1      pickup
cleanup  unix  n      -      -      -      0      cleanup
qmgr      fifo  n      -      n      300    1      qmgr
#qmgr    fifo  n      -      -      300    1      oqmgr
tlsmgr    unix  -      -      -      1000?  1      tlsmgr
rewrite  unix  -      -      -      -      -      trivial-rewrite
bounce    unix  -      -      -      -      0      bounce
defer    unix  -      -      -      -      0      bounce
trace    unix  -      -      -      -      0      bounce
verify    unix  -      -      -      -      1      verify
flush    unix  n      -      -      1000?  0      flush
proxymap  unix  -      -      n      -      -      proxymap
smtp      unix  -      -      -      -      -      smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay    unix  -      -      -      -      -      smtp
        -o fallback_relay=
#      -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq    unix  n      -      -      -      -      showq
error    unix  -      -      -      -      -      error
discard  unix  -      -      -      -      -      discard
local    unix  -      n      n      -      -      local
virtual  unix  -      n      n      -      -      virtual
lmtp      unix  -      -      -      -      -      lmtp
anvil    unix  -      -      -      -      1      anvil
scache          unix        -        -        -        -        1        scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -      n      n      -      -      pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -      n      n      -      -      pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -      n      n      -      -      pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp    unix  -      n      n      -      -      pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix        -        n        n        -        2        pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman  unix  -      n      n      -      -      pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

dovecot  unix  -      n      n      -      -      pipe
    flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}
retry    unix  -      -      -      -      -      error

main.cf:

Code:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = lt01.lt.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = lt01.lt.com, localhost.localdomain, localhost.lt.com, localhost
relayhost =
mynetworks = 127.0.0.0/8, 72.232.180.227
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 1024000000
recipient_delimiter = +
inet_interfaces = all
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf,mysql:/etc/postfix/mysql-email2email.cf
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

maximal_queue_lifetime = 12h
virtual_mailbox_limit = 1024000000
message_size_limit = 102400000

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination

smtpd_helo_required = yes
disable_vrfy_command = yes
strict_rfc821_envelopes = yes
invalid_hostname_reject_code = 554
multi_recipient_bounce_reject_code = 554
non_fqdn_reject_code = 554
relay_domains_reject_code = 554
unknown_address_reject_code = 554
unknown_client_reject_code = 554
unknown_hostname_reject_code = 554
unknown_local_recipient_reject_code = 554
unknown_relay_recipient_reject_code = 554
unknown_sender_reject_code = 554
unknown_virtual_alias_reject_code = 554
unknown_virtual_mailbox_reject_code = 554
unverified_recipient_reject_code = 554
unverified_sender_reject_code = 554


smtpd_recipient_restrictions =
            reject_invalid_hostname,
            reject_unknown_recipient_domain,
            reject_unauth_pipelining,
            permit_mynetworks,
            permit_sasl_authenticated,
            reject_unauth_destination,
        reject_rbl_client cbl.abuseat.org


Connecting to Mysql via mysql -u mailuser -h localhost -p works perfectly.

netstat returns the following relevant entries:

Code:


tcp        0      0 localhost.localdo:mysql *:*                    LISTEN

unix  2      [ ACC ]    STREAM    LISTENING    417595  /var/run/mysqld/mysqld.sock

unix  2      [ ACC ]    STREAM    LISTENING    413389  /var/spool/postfix/private/auth

unix  2      [ ACC ]    STREAM    LISTENING    413373  /var/run/dovecot/dict-server
unix  2      [ ACC ]    STREAM    LISTENING    413375  /var/run/dovecot/login/default


Really at a loss as to what else I can check. Mail not flowing is not a good state to be in.

gregster 20th April 2013 20:15

Also, it would appear that Dovecot and Roundcube can both authenticate me as I have no problems logging in and browsing my mailstore, just that I can no longer send/receive email.

aFoP 20th April 2013 20:19

Hi,
Is it possible that you've upgraded to "factory" postfix packages as well?
If you used the tutorial here, as far as I see during the tutorial postfix needs to be built from source with quota patches in it, so if you have upgraded to an unpatched postfix version it may not work .. just a hint.

gregster 20th April 2013 20:25

It could be, but what mystifies me is I upgraded a few weeks ago, and after solving one issue with mail not processing due to a name change in a plugin (and requiring a config file change), everything has been fine. I only noticed this yesterday, which seems very strange.

gregster 20th April 2013 20:38

Quote:

Originally Posted by gregster (Post 296104)
It could be, but what mystifies me is I upgraded a few weeks ago, and after solving one issue with mail not processing due to a name change in a plugin (and requiring a config file change), everything has been fine. I only noticed this yesterday, which seems very strange.

Solved by changing all the mysql-virtual* .cfs to 127.0.0.1. I'm really unsure what triggered this problem however, as things have been fine and I certainly didn't edit any configs. I initially noticed my server was unresponsive, seemingly due to mysql being pegged, rebooted it and then noticed no mail flow. Bizarre to say the least.


All times are GMT +2. The time now is 21:26.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.