Postfix doesn't connect to mysql for Generic map ONLY

Discussion in 'Server Operation' started by IceAndFire, Oct 16, 2013.

  1. IceAndFire

    IceAndFire New Member

    Hello,
    This forum has been a big help in the past via searches.
    But I've come across an issue that I am not understanding and cannot search a solution for.

    right now this is a dev server so I can mess around with it.

    My issue is with "smtp_generic_maps".

    This works:
    smtp_generic_maps = hash:/etc/postfix/gmap
    #smtp_generic_maps = mysql:/etc/postfix/mysql-smtp-generic-maps.cf

    This does not work.
    #smtp_generic_maps = hash:/etc/postfix/gmap
    smtp_generic_maps = mysql:/etc/postfix/mysql-smtp-generic-maps.cf

    /etc/postfix/gmap:
    Code:
    [email protected]	[email protected]
    /etc/postfix/mysql-smtp-generic-maps.cf:
    Code:
    user = mysqluser
    password = mysqlpassword
    hosts = 127.0.0.1
    dbname = mailserver
    query = SELECT source FROM virtual_aliases WHERE (destination=`%s`) LIMIT 1
    When I run the query manually I get:
    Code:
    SELECT source FROM virtual_aliases WHERE [email protected]' LIMIT 1
    
    Output: [email protected]
    I copied /etc/postfix/mysql-smtp-generic-maps.cf from another mysql-xxxx.cf file that works fine.

    Looking at MySQL's history I can see mysql-smtp-generic-maps.cf never ran while mysql-xxxx.cf runs just fine.

    The postmap logs are:
    Code:
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: dict_mysql_get_active: attempting to connect to host 127.0.0.1
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: warning: connect to mysql server 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (0)
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: event_cancel_timer: 0xb70feae0 0xb9039be8 -1
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: warning: mysql:/etc/postfix/mysql-smtp-generic-maps.cf lookup error for "[email protected]"
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: maps_find: smtp_generic_maps: [email protected]: search aborted
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: mail_addr_find: [email protected] -> (try again)
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: mail_addr_map: [email protected] -> (try again)
    Oct 16 14:25:22 CleanInstall1 postfix/smtp[9170]: fatal: smtp_generic_maps map lookup problem for [email protected]
    Oct 16 14:25:23 CleanInstall1 postfix/error[9179]: 27BFC5B0: to=<[email protected]>, orig_to=<[email protected]>, relay=none, delay=4.4, delays=0.02/4.4/0/0.01, dsn=4.3.0, status=deferred (unknown mail transport error)
    

    So to recap, when using smtp-generic-maps as a hash it works fine. When using MySQL it never even connects to run the query while other mysql maps which are virtually identical run perfectly.


    here is my postconf -n
    Code:
    append_dot_mydomain = no
    biff = no
    config_directory = /etc/postfix
    debug_peer_level = 3
    debug_peer_list = 127.0.0.1, 127.0.69.0
    ignore_mx_lookup_error = yes
    inet_interfaces = all
    mailbox_size_limit = 0
    mydestination = localhost
    myhostname = CleanInstall1.example.com
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    readme_directory = no
    recipient_canonical_maps = mysql:/etc/postfix/mysql-recipient-canonical-maps.cf
    recipient_delimiter = +
    relayhost = [smtp.gmail.com]:587
    smtp_generic_maps = mysql:/etc/postfix/mysql-smtp-generic-maps.cf
    smtp_host_lookup = native
    smtp_sasl_security_options = noanonymous
    smtp_sender_dependent_authentication = yes
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtp_tls_mandatory_ciphers = high
    smtp_tls_security_level = encrypt
    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
    smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_path = private/auth
    smtpd_sasl_type = dovecot
    smtpd_tls_auth_only = yes
    smtpd_tls_cert_file = /etc/dovecot/dovecot.pem
    smtpd_tls_key_file = /etc/dovecot/private/dovecot.pem
    smtpd_use_tls = yes
    transport_maps = hash:/etc/postfix/transport
    virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
    virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
    virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
    virtual_transport = lmtp:unix:private/dovecot-lmtp
    
     

Share This Page