main.cf.j2 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. {% if ansible_controlled is defined and ansible_controlled != "" %}
  2. #
  3. # {{ ansible_controlled }}
  4. #
  5. {% endif %}
  6. # See /usr/share/postfix/main.cf.dist for a commented, more complete version
  7. # Debian specific: Specifying a file name will cause the first
  8. # line of that file to be used as the name. The Debian default
  9. # is /etc/mailname.
  10. {% if ansible_lsb.major_release|int >= 9 %}
  11. # Compatibility level
  12. compatibility_level = 3
  13. {% endif %}
  14. smtpd_banner = $myhostname ESMTP $mail_name
  15. biff = no
  16. # appending .domain is the MUA's job.
  17. append_dot_mydomain = no
  18. # Uncomment the next line to generate "delayed mail" warnings
  19. #delay_warning_time = 4h
  20. readme_directory = no
  21. # TLS parameters
  22. smtpd_tls_security_level = may
  23. smtpd_tls_loglevel = 1
  24. smtpd_tls_received_header = yes
  25. smtpd_tls_ask_ccert = yes
  26. smtpd_tls_req_ccert = no
  27. smtpd_tls_auth_only = yes
  28. smtpd_tls_mandatory_ciphers = high
  29. smtpd_tls_mandatory_exclude_ciphers = aNULL, RC4, MD5
  30. smtpd_tls_protocols = !SSLv2, !SSLv3
  31. smtpd_tls_dh1024_param_file = /etc/ssl/private/dh2048.pem
  32. smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
  33. smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
  34. smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
  35. smtpd_tls_session_cache_timeout = 3600
  36. smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
  37. smtp_tls_security_level = may
  38. smtp_tls_loglevel = 1
  39. smtp_tls_note_starttls_offer = yes
  40. smtp_tls_cert_file = $smtpd_tls_cert_file
  41. smtp_tls_key_file = $smtpd_tls_key_file
  42. smtp_tls_mandatory_ciphers = $smtpd_tls_mandatory_ciphers
  43. smtp_tls_mandatory_exclude_ciphers = $smtpd_tls_mandatory_exclude_ciphers
  44. smtp_tls_protocols = $smtpd_tls_protocols
  45. smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
  46. smtp_tls_session_cache_timeout = 3600
  47. smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
  48. {% if postfix_fqdn is defined %}
  49. myhostname = {{ postfix_fqdn }}
  50. {% else %}
  51. myhostname = {{ ansible_fqdn }}
  52. {% endif %}
  53. myorigin = $myhostname
  54. mydomain = $myhostname
  55. mydestination = $myhostname {% if postfix_hostname is defined %}{{ postfix_hostname }}{% else %}{{ ansible_hostname }}{% endif %} localhost localhost.localdomain
  56. {% if smtp_relay_host is defined %}
  57. relayhost = {{ smtp_relay_host }}
  58. {% elif with_postfix_external_smtp|bool %}
  59. smtp_sasl_auth_enable = yes
  60. smtp_sasl_security_options = noanonymous
  61. smtp_sasl_password_maps = hash:/etc/postfix/sasl/credentials
  62. smtp_sasl_mechanism_filter = login plain
  63. smtp_sender_dependent_authentication = yes
  64. sender_dependent_relayhost_maps = hash:/etc/postfix/sasl/sender_relay
  65. {% if postfix_external_smtp_host_localdomain %}
  66. smtpd_sasl_local_domain = {{ postfix_external_smtp_host_localdomain }}
  67. {% endif %}
  68. {% if postfix_external_sender_rewrites %}
  69. sender_canonical_maps = regexp:/etc/postfix/sasl/sender_rewrite
  70. {% endif %}
  71. {% endif %}
  72. alias_maps = hash:/etc/aliases
  73. alias_database = $alias_maps
  74. {% if with_postfix_slowsmtp|bool %}
  75. transport_maps =
  76. hash:/etc/postfix/transport_slowsmtp
  77. slowsmtp_destination_recipient_limit = 20
  78. slowsmtp_destination_concurrency_limit = 2
  79. {% endif %}
  80. {% if smtp_relay_domains is defined %}
  81. relay_domains =
  82. {% for domain in smtp_relay_domains %}
  83. {{ domain}}
  84. {% endfor %}
  85. {% endif %}
  86. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 {% if postfix_mynetworks is defined %}{{ postfix_mynetworks }}{% endif %}
  87. mailbox_command = procmail -a "$EXTENSION"
  88. mailbox_size_limit = 0
  89. message_size_limit = 0
  90. recipient_delimiter = +
  91. inet_interfaces = all
  92. disable_vrfy_command = yes
  93. smtpd_recipient_restrictions =
  94. permit_mynetworks,
  95. reject_non_fqdn_sender,
  96. reject_non_fqdn_recipient,
  97. reject_unknown_sender_domain,
  98. reject_unauth_destination,
  99. reject_unknown_recipient_domain,
  100. permit
  101. smtpd_client_restrictions =
  102. permit_mynetworks,
  103. reject_unauth_pipelining,
  104. reject_unauth_destination
  105. smtpd_helo_required = yes
  106. smtpd_helo_restrictions =
  107. permit_mynetworks,
  108. reject_non_fqdn_helo_hostname,
  109. reject_invalid_helo_hostname
  110. smtpd_sender_restrictions =
  111. permit_mynetworks,
  112. reject_non_fqdn_sender,
  113. reject_unknown_sender_domain
  114. {% if with_opendkim is defined and with_opendkim|bool %}
  115. # DKIM support
  116. milter_default_action = accept
  117. smtpd_milters = inet:localhost:8891
  118. non_smtpd_milters = inet:localhost:8891
  119. {% endif %}
  120. {% if postfix_config is defined %}
  121. # Additionnal configuration
  122. {% for key in postfix_config %}
  123. {{ key }} = {{ postfix_config[key] }}
  124. {% endfor %}
  125. {% endif %}