<p>I'm not sure I'm using all the correct terminology here so be forgiving.</p>

<p>I just put up a site with a contact form that sends an email using the PHP mail() function. Simple enough. However the live site doesn't actually send the email, the test site does. So it's not my code. </p>

<p>It's a shared host and we have another site that has the same function that works perfectly, so it's not the server. </p>

<p>The only difference between the two is that the site that doesn't work just has the name server pointing to us and so the MX record never touches our server. </p>

<p>So my question is, could some one please confirm that the mail() function wont work if we don't have the MX record pointing to our server. Thanks</p>

[{'answer_id': 38672, 'author': 'paan', 'author_id': 2976, 'author_profile': 'https://Stackoverflow.com/users/2976', 'pm_score': 0, 'selected': False, 'text': "<p>Yes, you could put in what ever you want in the 'from' field and it would still work.</p>\n"}, {'answer_id': 38678, 'author': 'Dan Walker', 'author_id': 752, 'author_profile': 'https://Stackoverflow.com/users/752', 'pm_score': 2, 'selected': False, 'text': "<p>Yes. It will work just fine. I have a PHP script using the mail() function with the MX records set to Google Apps.</p>\n\n<p>If the two scripts are on different hosts (it's a bit unclear from your post), then make sure that the host doesn't block some of the custom headers. I had issues with this when creating my script, but removing all but the From header fixed the problem.</p>\n"}, {'answer_id': 39673, 'author': 'Eric Goodwin', 'author_id': 1430, 'author_profile': 'https://Stackoverflow.com/users/1430', 'pm_score': 2, 'selected': False, 'text': '<p>Some hosts (Godaddy is the worst) block your use of sendmail and mail().  </p>\n\n<p>I generally use smtp to send emails from my php applications and with <a href="http://phpmailer.codeworxtech.com/" rel="nofollow noreferrer">PHPMailer</a> it\'s super easy.  Many applications are using older versions of PHPMailer and sometimes updating it can help.  It\'s also easy enough to add quickly to short scripts as well.</p>\n'}, {'answer_id': 432807, 'author': 'user19471', 'author_id': 19471, 'author_profile': 'https://Stackoverflow.com/users/19471', 'pm_score': 1, 'selected': False, 'text': "<p>The <code>mail()</code> function sends mail from the server hosting the script.  Since many shared hosting providers host separate mail servers, and because the <code>mail()</code> function doesn't support any sort of authentication, many shared hosting providers block it.</p>\n"}, {'answer_id': 432878, 'author': 'Brian Rasmussen', 'author_id': 38206, 'author_profile': 'https://Stackoverflow.com/users/38206', 'pm_score': 1, 'selected': False, 'text': '<p>If the site uses SPF, remember to include the sending site in your SPF record. For more info see <a href="http://www.openspf.org/" rel="nofollow noreferrer">here</a>. </p>\n'}, {'answer_id': 580095, 'author': 'cole', 'author_id': 910, 'author_profile': 'https://Stackoverflow.com/users/910', 'pm_score': 3, 'selected': True, 'text': '<p>Hey guys thanks for the answers, it is really appreciated.</p>\n\n<p>After ignoring the issue for a few months it has come up again, I did however find the answer to my problems.</p>\n\n<p>Firstly, as you answers suggested, PHP and the mail() function were working as expected. The mail was getting sent.</p>\n\n<p>The problem lies when the email is sent, it simply presumes that because its being sent from mydomain.com to *@mydomain.com email that the email itself is hosted on the same server, so it gets sent there instead and ignores the MX record. </p>\n\n<p>OK it\'s a bit more complicated than that, but that is the general jist.</p>\n\n<p>Edit:\nFound a better version of the topic <a href="https://stackoverflow.com/questions/322659/sendmail-and-mx-records-when-mail-server-is-not-on-web-host">sendmail and MX records when mail server is not on web host</a>.</p>\n'}]
['https://Stackoverflow.com/questions/38669', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/910/']