Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I manage a hosting for a domain (let's say The machine is not attached to a public domain (as it hosts more domains), and hostname is is a Wordpress application

It has Postfix installed, to allow local applications to send emails. It doens't have the MX records associated. I know this could be a problem, but the client doesn't matter by the moment as he only throws emails to a reduced group and it's been working (we've just migrated the hosting to another machine in another IP) till now. I've tried to avoid rewriting but

The facts are:

A PHP mail() command changes FROM to

Jul  9 13:51:02 albergues02 sendmail[919]: q69Bp2F1000919: from=apache, size=148, class=0, nrcpts=1, msgid=<>, relay=apache@localhost
Jul  9 13:51:02 albergues02 postfix/smtpd[921]: connect from localhost[]
Jul  9 13:51:02 albergues02 postfix/smtpd[921]: D7B0960E77: client=localhost[]
Jul  9 13:51:02 albergues02 postfix/cleanup[924]: D7B0960E77: message-id=<>
Jul  9 13:51:02 albergues02 postfix/qmgr[787]: D7B0960E77: from=<>, size=607, nrcpt=1 (queue active)
Jul  9 13:51:02 albergues02 sendmail[919]: q69Bp2F1000919:, ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30148, relay=[] [], dsn=2.0.0, stat=Sent (Ok: queued as D7B0960E77)
Jul  9 13:51:02 albergues02 postfix/smtpd[921]: disconnect from localhost[]

If I "Remember my password" from login page, mail gets OK (FROM keeps being

Jul  9 13:55:23 albergues02 postfix/smtpd[938]: connect from localhost[::1]
Jul  9 13:55:23 albergues02 postfix/smtpd[938]: 51BB260E79: client=localhost[::1]
Jul  9 13:55:23 albergues02 postfix/cleanup[942]: 51BB260E79: message-id=<>
Jul  9 13:55:23 albergues02 postfix/qmgr[787]: 51BB260E79: from=<>, size=968, nrcpt=1 (queue active)
Jul  9 13:55:23 albergues02 postfix/smtpd[938]: disconnect from localhost[::1]
Jul  9 13:55:23 albergues02 postfix/smtp[943]: 51BB260E79: to=<>,[]:25, delay=0.19, delays=0.05/0.02/0/0.11, dsn=2.0.0, status=sent (250 ok:  Message 39109407 accepted)
Jul  9 13:55:23 albergues02 postfix/qmgr[787]: 51BB260E79: removed

The wordpress has a Newsletter sending plugin that doesn't work, neither.

Postconf -n shows:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
anvil_rate_time_unit = 1s
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
inet_protocols = all
local_header_rewrite_clients =
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
masquerade_domains = ! ! # All domains that appear in the @domain of the emails sent
mydestination = $myhostname, localhost.$mydomain, localhost
mydomain =
myhostname =
mynetworks_style = host
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
remote_header_rewrite_domain =
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_client_connection_count_limit = 30
smtpd_client_connection_rate_limit = 100
smtpd_client_message_rate_limit = 100
smtpd_client_recipient_rate_limit = 100
smtpd_client_restrictions = permit
smtpd_error_sleep_time = 1s
smtpd_hard_error_limit = 20
smtpd_soft_error_limit = 10
unknown_local_recipient_reject_code = 550

Sendmail is installed on the machine but service is stopped.

I don't know what else to change/look/configure. The goal is to make postfix to relay all mails that come from localhost without rewriting the FROM address.

share|improve this question
I'm not sure I could figure out what the question is. Could you add a summary at the bottom? Also, I noticed sendmail[919]: lines in the first logfile. Are you running Sendmail and Postfix on the same box? If so, the Sendmail config might be helpful too. – Ladadadada Jul 9 '12 at 16:07
Changed. I want to relay all mails coming from localhost without rewriting FROM. Sendmail is installed but service is stopped. – Mike B Jul 9 '12 at 16:12
up vote 2 down vote accepted

I have to disagree with your assertion that sendmail is not running. The log file above shows that it accepted an email from Apache and relayed it to Postfix. If it wasn't running, it wouldn't write to the mail log. It also wouldn't have the PID 919.

Since Sendmail and Postfix do the same thing, you really only want one of them. Personally, I find Postfix much easier to deal with.

I also think that you are sending mail from PHP in two different ways and this is the root of your "rewriting" problem. One of the ways is using the /usr/bin/sendmail binary (this is the default with the PHP mail() command), the other is by connecting to localhost on port 25 and talking SMTP. Presumably this is done with a package like SwiftMail or similar.

Postfix installs its own /usr/bin/sendmail binary with the same interface as the Sendmail version ( or rather it symlinks its own version at that location ) but if Sendmail's sendmail is there instead, any mails sent using that binary will go into the Sendmail system.

My recommendation would be to uninstall both Sendmail and Postfix and then re-install Postfix. This will ensure that the correct binaries are in the correct location.

share|improve this answer
Both erased, postfix reinstalled. Sendmail, as you said, is not showing anymore (out of the question, but why it did when I double checked "service sendmail stop" and master listening on 25?). You made the light with the difference between connecting throug SMTP or executing PHP mail command. SMTP works OK, PHP mail appears in logs as "from=<>". I'm starting to think that this is correct, as apache is the user that is actually sending the email. I thought you could have both sendmail and postfix installed, but I learnt to be careful with sendmail.xx command. – Mike B Jul 9 '12 at 21:09
After all this, I'll tell my client to connect via SMTP. The answer helped a lot to clarify myself, so I'll check it as the answer. Only remaining the curiosity about PHP mail command. Does it (FROM being the address of the user running the command) always happen? – Mike B Jul 9 '12 at 21:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.