main.cf.j2 3.9 KB

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