diff --git a/templates/msmtprc.j2 b/templates/msmtprc.j2
index e205a4947f2213891e1bbb6f22620860d8c02641..495bd1dd1754fc1960f3374608123ffe45dac195 100644
--- a/templates/msmtprc.j2
+++ b/templates/msmtprc.j2
@@ -8,3 +8,7 @@ from {{ msmtp_from }}
 {% endif %}
 host {{ msmtp_relay_relayhost }}
 aliases /etc/aliases
+{% if msmtp_auto_from_domain is defined %}
+auto_from on
+maildomain {{ msmtp_auto_from_domain }}
+{% endif %}