0

I have a PHP script running on a Windows web server, running PHP 5.

The script works fine when I send to an email that is NOT on the domain, but when I try and send to an email that IS on the domain, I get a 500 internal server error. Here's code that fails, assuming the website is www.mydomain.com

<?php
ini_set('sendmail_from', 'dan@mydomain.com');
mail('anything@mydomain.com', 'Test', 'This is a test');
?>

If I change the to field to anything@someotherdomain.com, it works fine. Removing or modifying the ini_set does nothing.

I've checked a few PHP ini settings but can't see any reason it'd fail for just this one domain.

Ryan
  • 3,552
  • 1
  • 22
  • 39
Dan Walker
  • 434
  • 1
  • 5
  • 15
  • 2
    This seems to be a problem with the mailserver and not php – Ayush Jan 29 '14 at 08:21
  • 1
    Enable all errors in php.ini and check the log file. There must be some error message somewhere. – laurent Jan 29 '14 at 08:22
  • 2
    Is it really necessary to change the php.ini settings for that?? You can do everything you need directly in the script. http://stackoverflow.com/questions/5335273/how-to-send-mail-using-php – dev7 Jan 29 '14 at 08:23
  • 1
    The email isn't getting as far as the mail server, I've got a grep on /var/log/maillog on the server and the email never arrives. I'll enable PHP error logging and check but didn't see any in the local error_log IIRC. – Dan Walker Jan 29 '14 at 08:30
  • Hi Ryan, I searched and read a few posts but didn't see that one, I'll have a look through it now – Dan Walker Jan 29 '14 at 08:37
  • I've done some debugging, it seems the mail isn't even reaching the MTA. If I use my personal email (domain redacted), it appears in the log `01/29/14 09:42:55 [EA0026FEFC374CB2895C11067897DB4B.MAI] from (SMTP) [SMTP:dwalker@mydomain.com]->[SMTP:dwalker@mydomain.com] System Default Route Applied.` But to the local domain don't even hit the log. – Dan Walker Jan 29 '14 at 09:44

0 Answers0