0

I manage a hosting for a domain (let's say sendingdomain.com). The machine is not attached to a public domain (as it hosts more domains), and hostname is albergues02.resolve.com. Sendingdomain.com 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 [email protected]:

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

If I "Remember my password" from login page, mail gets OK (FROM keeps being [email protected]):

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=<[email protected]>
Jul  9 13:55:23 albergues02 postfix/qmgr[787]: 51BB260E79: from=<[email protected]>, 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=<[email protected]>, relay=vmail.mycompany.es[217.xxx.xx.xx]: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 = !domain.com !domain2.com # All domains that appear in the @domain of the emails sent
mydestination = $myhostname, localhost.$mydomain, localhost
mydomain = resolve.com
myhostname = albergues02.resolve.com
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.

2
  • 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, 2012 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, 2012 at 16:12

1 Answer 1

2

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.

2
  • 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=<[email protected]>". 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, 2012 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, 2012 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .