Need some help for postfix configuration (relay to different domains and more)

Discussion in 'Server Operation' started by voltron81, Jan 26, 2010.

  1. voltron81

    voltron81 New Member

    Hi to everybody.
    I'm realizing a postfix mailserver following this howto:

    Basically I want to hold all emails to be sent (I'll send them manually when I want), plus I want to relay all the emails to different smtp servers (depends of the email).

    So, more or less the of postfix look like that (I'll post just the important parts):
    # TLS parameters
    smtpd_tls_cert_file = /etc/postfix/smtpd.cert
    smtpd_tls_key_file = /etc/postfix/smtpd.key
    smtpd_use_tls = yes
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    smtpd_tls_CAfile = /etc/postfix/cacert.pem
    smtpd_tls_received_header = yes
    smtpd_tls_ask_ccert = yes
    smtpd_tls_loglevel = 1
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    smtp_tls_CAfile = /etc/postfix/cacert.pem
    smtp_tls_cert_file = /etc/postfix/smtpd.cert
    smtp_tls_key_file = /etc/postfix/smtpd.key
    smtp_use_tls = yes
    smtp_tls_scert_verifydepth = 5
    smtp_tls_loglevel = 1
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_type = cyrus
    smtp_sasl_security_options = noanonymous
    smtp_sasl_tls_security_options = $smtp_sasl_security_options
    smtp_sasl_tls_verified_security_options = $smtp_sasl_security_options
    smtp_tls_loglevel = 2
    smtpd_sasl_auth_enable = yes
    broken_sasl_auth_clients = yes
    smtpd_sasl_authenticated_header = yes
    smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
    relayhost =
    virtual_alias_domains =
    virtual_alias_maps = proxy:mysql:/etc/postfix/, mysql:/etc/postfix/
    virtual_mailbox_domains = proxy:mysql:/etc/postfix/
    virtual_mailbox_maps = proxy:mysql:/etc/postfix/
    virtual_mailbox_base = /var/vmail
    transport_maps = proxy:mysql:/etc/postfix/
    relay_domains =  mysql:/etc/postfix/
    sender_dependent_relayhost_maps = hash:/etc/postfix/bysenderrelay
    defer_transports = hold
    default_transport = hold
    proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains 
    $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks 
    As users I've email from my main mailserver and emails from gmail, hotmail, yahoo, etc...
    To relay emails to gmail(or every smtp server that require CA), I've created a CA (following this howto:


    The problems that I've are:
    1) I've setup in bysenderrelay the relay policy dependent of the sender, and in the database mail_transport(used by, I've write

    all local emails, like that:
    I did't put the value:
    *	smtp:[]
    because otherwise I was not able to use the feature sender_dependent_relayhost_maps (all the email not direct to an internal account will be relayed to
    It's working fine for internal emails, but if I've as local email [email protected] and I want to send an email to [email protected], postfix think that gmail is a local domain and he believe that [email protected] is a local email.

    2) After the configuration of the CA, I'm able to relay correctly emails to gmail and hotmail, but not to yahoo (I know that yahoo is working even without SSL, but I want that postfix will work with all the servers)

    3) about the mail queued(the ones that needs to be sent), there is a way to see the subject of them? With mailq I can not see it

    I hope somebody can give me some suggestions...

  2. voltron81

    voltron81 New Member

    About the problem n.1, I guess the problem is in the tables mail_domains.

    Basically in postfix I've:
    virtual_mailbox_domains = proxy:mysql:/etc/postfix/
    and in that file there is this query:
    SELECT domain AS virtual FROM mail_domains WHERE domain = '%s';
    Now, in the table mail_domains I've the domain '', because I've some local email addresses with gmail.
    So with '' in mail_domains, I can correctly send internal emails, but not to external gmail accounts.
    If I remove '' from mail_domains, I'll send correctly emails to external gmail accounts, but no anymore to the internal gmail accounts...
    What I'm doing wrong?

  3. voltron81

    voltron81 New Member

    As far as I can see, the idea to solve the point n.1 should be:
    - since the nexthop destination is taken from relay_transport, sender_dependent_relayhost_maps and relayhost, I'll put the local emails as result of relay_domains (with relay_tranport=virtual) and the external emails in sender_dependent_relayhost_maps.

    The problem is that the postfix variable %s is giving me the domain of the sender, not the complete email address... and I can not match what I want in the select of relay_domains.
    I tried using also %u or %d, but nothing...

    Any idea?

  4. voltron81

    voltron81 New Member



Share This Page