I've setup postfix on my VPS Ubuntu 18.04 and I've followed guides to setup DKIM, DMARC and SPF. I have multiple domains on the server and I'm trying to send email from a domain which is not the same as my hostname. (sending via php mail() function)
I have sent an email to Gmail and I've got 3 passes:
dkim=pass [email protected] header.s=default header.b="xxxxxx/M";
spf=pass (google.com: domain of [email protected] designates 11.22.33.44 as permitted sender) [email protected];
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=second-domain.com
I think Gmail is giving me a pass on SPF because of IP validation.
Checked my email score with mailgenius.com:
(-2 points) Your "from" address does not match your SPF "from" address.
Solution:
Make sure your SPF authentication is setup correctly so your SPF from domain matches the from domain in your emails.
Your From domain is: second-domain.com
Your SPF MailFrom domain is: hostname.com
I don't know where to modify postfix to change the spf mailfrom to match the sender domain and not the hostname? Is it possible to do so?
edit: setting up smtp_generic_maps in main.cf does change those values:
smtp_generic_maps = hash:/etc/postfix/generic
/etc/postfix/generic:
[email protected] second-domain.com
That does change the output and kinda works. That is just hard-coded for one domain.I need to detect which domain is used to replace [email protected]