sendmail and MX records when mail server is not on web host
Asked Answered
E

7

4

This is a problem I'm sure is easy to fix, but I've been banging my head on it all day.

I'm developing a new web site for a client. The web site resides at (this is an example) website.com. I have a PHP form script to email visitors' requests to [email protected].

When I coded this on a staging server on a different domain, all worked fine. When I moved it to website.com, the mail messages never arrived. The web server is on a virtual host with a major ISP.

Here's what I've learned since then: My client's mail server is Microsoft Exchange on a box physically in their office. Whenever someone on the outside world emails [email protected], the mail arrives. But if the web server sends to the same email address, it fails every time. This is not a PHP problem. I secure shell in to the web server and have tested this both with sendmail and the UNIX mail application. I've also tested it by emailing various email accounts from the shell. I can email myself, for example, just nobody at the website.com domain.

In short, when I'm logged in to website.com, mail to [email protected], [email protected], [email protected] all fail. All other addresses work fine. What I've discovered is those dropped emails are routed to the web server's "catchall" account where they sit in its inbox.

I've done an MX lookup on website.com. The MX record points to mailsec.website.com. I can telnet to mailsec.website.com port 25 and see the SMTP server.

It appears to me that website.com isn't doing an MX lookup when it's sending mail to [email protected]. My theory is that it recognizes the domain as local, sees that there's no "requests" user account to deliver it to, and drops the mail into the catchall account. What I want is to force sendmail to do the MX lookup and send the message on to the Exchange server. I'm at wit's end here. I can't figure out how to do this.

For that matter, I may be way off base here and have misdiagnosed this entirely. Internet mail and MX has always seemed a black art to me, and my ignorance is certainly showing in this question.

Eel answered 27/11, 2008 at 0:56 Comment(1)
Look at the discussion at serverfault.com/questions/98283/…. The response from Pawel did it for me.Folie
H
9

I think the problem is that sendmail (your process) is talking to the local sendmail daemon. The local sendmail daemon thinks that because it is website.com, it should know how to deliver the email. Unfortunately, the actual address in the to field does not exist on the web server and thus it dumps it in the "catchall" mail box. You should talk to your ISP and have them update their sendmail configuration so that mail addressed to [email protected] gets forward to the mail exchanger instead of being handled locally.

Hospitium answered 27/11, 2008 at 2:28 Comment(0)
H
4

Sendmail by default guesses list of local email domains. It can be turned off using the following line in your sendmail.mc file:

define(`confDONT_PROBE_INTERFACES',`True')

As root list local email domains before and after the change using:

echo '$=w' | sendmail -Am -bt

You will see which domains should be added "manually" to (usually) /etc/mail/local-host-names file after disabling auto-guessing.

After changing sendmail.mc:

  1. Generate/compile new sendmail.cf file
  2. Restart sendmail daemon (or send HUP signal)
Hoppe answered 6/3, 2013 at 12:13 Comment(0)
E
1

tvanfosson basically has it, but as a temporary workaround, you should be able to change your script so that it mails '[email protected]', and then the mail will get delivered to the actual mail server.

Enjoin answered 27/11, 2008 at 3:44 Comment(0)
A
0

Edit the tsm.cf file (in /etc/mail/ or similar) to include

FEATURE(relay_entire_domain) 

between the DOMAIN() and MAILER() lines. Since you're editing the file, you may want to also improve security with

define(`confPRIVACY_FLAGS',``noexpn,novrfy'')

After changing the tsm.cf file (or any sendmail config file), restart or SIGHUP the sendmail process.

This change is necessary because the WWW and MX servers for the domain do not exist in the same process space; this FEATURE triggers sendmail to process messages for the domain using it's external delivery mechanism.

The edited portion of the tsm.cf file should look similar to this:

DOMAIN(website.com)dnl
FEATURE(relay_entire_domain)dnl
define(`confPRIVACY_FLAGS',``noexpn,novrfy'')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
Ammonate answered 1/4, 2009 at 13:41 Comment(0)
J
0

What worked for me was to add an MX record on the webserver hosting the website, that points to the host assigned on the original domain name server. In the case presented here would be an mx record pointing to: mailsec.website.com

Jaan answered 1/1, 2011 at 22:49 Comment(0)
M
0

I'm new here. Wanted to extend RB_CWI answer, but I am not allowed to comment. His solution worked great.

You are not required to define the DOMAIN().

However, on my system I was required to install the sendmail-cf package.

The instructions below were done on CentOS 6.5

First, install sendmail-cf

sudo yum install sendmail-cf

Then, edit the senmail.mc

sudo vi /etc/mail/sendmail.mc

At the bottom of the file add FEATURE(relay_entire_domain)dnl, so it looks like:

...
FEATURE(relay_entire_domain)dnl
MAILER(smtp)dnl        # right above this line
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl

Save the file, and restart sendmail.

sudo service sendmail restart
Monoicous answered 30/5, 2015 at 19:29 Comment(0)
T
0

Got stuck on the same problem. MX points to an external Exchange server but php/sendmail did not lookup this record. Instead mails posted by WordPress on this webserver dropped in the catchall-mailbox.

Solution was to delete ALL mailboxes on the webserver. Now sendmail was interested in the MX and all mails went to the Exchange.

However, the Exchange uses the webspace's mail server as SmartHost for outgoing mails. As solution for this, we were able to use the FTP credentials for accessing the mail server. I assume this solution does not work on every provider on this planet, but in our case (all-inkl.com) it worked out.

Theodoratheodore answered 1/10, 2018 at 7:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.