main.cf.j2 4.4 KB

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