Php – Exim4 envelope-from using PHP mail()

eximPHPsendmail

I've set up an exim4 server for sending email only on Debian Sid.

If I just send an email it works fine and the email is delivered in my inbox. However, if I send an email using WordPress it is delivered in my spam box.

I think this is caused by:

envelope-from <www-data@example.com>
Return-Path: www-data@example.com
From: WordPress <wordpress@example2.com>

The headers don't match. Could this cause this problem? Note the difference between example.com and example2.com.

I've tried setting the following line in exim4's configuration but it doesn't help (the headers are not changed):

Of course I've restarted exim4 after that.

MAIN_TRUSTED_USERS = uucp : www-data
[...]
trusted_users = MAIN_TRUSTED_USERS
untrusted_set_sender = *

I've set SPF records:

These may not have been resolved yet, could this be the problem?

example.com:  "v=spf1 ptr -all"
example2.com: "v=spf1 include:example.com -all"

WordPress should use the -f parameter for sendmail because it uses the PHPMailer class which does so by default. However, I would like to solve this at exim4's level (possibly use the From header for envelope-from and Return-Path).

I don't care if other users can send emails from another email address too, because www-data is basically the only user on this server.

If you need any more information please ask me.


I added the following lines:

local_from_check = false
local_sender_retain = true
untrusted_set_sender = *

But it's still not working.

Best Answer

WP should be configured to send messages via SMTP protocol. Usually local submission performed via socket/LMTP where local user the web-server owner is used as sender. When it is the www@localhost MTAs become very strict.