Page 1 of 1

mail() problems

Posted: Fri Mar 02, 2007 12:04 pm
by jonathant
A client has a website that is remotely hosted on a shared server. He also has an exchange server that listens for mail sent his domain name, which is the same domain name as his website. So, the MX records for the domain name are pointed to his exchange IP address while the DNS records are pointed to the website server IP address. Make sense?

On the website I have a form that customers fill out. I want the results from the form to be sent to the sales guy. I'm just using mail(). The mail never makes it to the exchange server. If I check for the mail on the web host's webmail, I can find it there. If I send the mail to my personal email account (ie, any account that isn't the same domain name as the website) the mail makes it.

Is this a PHP or a DNS problem? Can I trick PHP to send the mail to an IP address rather than the domain name, like user@122.22.22.22?

Posted: Fri Mar 02, 2007 1:42 pm
by RobertGonzalez
I think you can use Swiftmailer (http://www.swiftmailer.org) to address that issue. I think mail() uses sendmail as a default, which might be causing you problems. Another thing to do is test mail() using a conditional to see if it was accepted my the mail server for delivery.

Code: Select all

<?php
if (mail($to, $subject, $msg))
{
  echo 'It was accepted for delivery';
}
else
{
  echo 'Crapola';
}
?>

Posted: Sat Mar 03, 2007 5:17 am
by Chris Corbyn
If you use Swift Mailer then the simplest solution would be to simply send the email straight to the exchange server by IP, using the SMTP connection.