Files
computer-playbook/roles/sys-svc-mail-msmtp/templates/msmtprc.conf.j2

30 lines
1.3 KiB
Django/Jinja

{% set email = lookup('email') %}
{% set ca_injected = sys_svc_mail_msmtp_in_container | bool and lookup('ca_injected', application_id) %}
{% set smtp_target = lookup('smtp_host', email, in_container=sys_svc_mail_msmtp_in_container) %}
defaults
domain {{ DOMAIN_PRIMARY }}
logfile ~/.msmtp.log
timeout {{ email.timeout }}
syslog {{ MODE_DEBUG | on_off }}
auth {{ email.auth_mechanism }}
tls_starttls {{ email.start_tls | on_off }}
tls {{ email.tls | on_off }}
{% if ca_injected %}
tls_trust_file {{ CA_TRUST.inject_bundle_container }}
{% endif %}
tls_host_override {{ email.host }}
{% if smtp_target.endswith('.onion') %}
{% set socks = (lookup('tor_socks_proxy') | regex_replace('^socks5h://', '')) if sys_svc_mail_msmtp_in_container | bool else lookup('tor_socks') %}
proxy_host {{ socks.split(':')[0] }}
proxy_port {{ socks.split(':')[1] }}
{% endif %}
account system_email_no_reply
host {{ smtp_target }}
port {{ email.port }}
from {{ email['from'] }}
{% if (email.auth | bool) %}
user {{ email.username }}
password {{ email.password }}
{% endif %}
account default : system_email_no_reply