Hi All,
I'm trying to get PHP to send mail to the outside world - which I might need to do one day if I decide to open up my webserver to the net...
This is my little testing script:
Code:
<?php
$fd = popen("/usr/sbin/sendmail -t","w");
fputs($fd, "To: someone@a.real.address.com\n");
fputs($fd, "From: Me \n");
fputs($fd, "Subject: Test message from my web site\n");
fputs($fd, "X-Mailer: PHP3\n");
fputs($fd, "Testing.\n");
pclose($fd);
?>
When I run it it fails with the following error:
Code:
Date: Mon, 3 Jul 2006 17:35:35 +0100
From: Mail Delivery Subsystem <MAILER-DAEMON@localhost.localdomain>
To: <apache@localhost.localdomain>
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)
[-- Attachment #1 --]
[-- Type: text/plain, Encoding: 7bit, Size: 0.6K --]
The original message was received at Mon, 3 Jul 2006 17:35:33 +0100
from ArthurDent [127.0.0.1]
----- The following addresses had permanent fatal errors -----
<someone@a.real.address.com>
(reason: 550-Verification failed for <apache@localhost.localdomain>)
----- Transcript of session follows -----
... while talking to punt-1.mail.demon.net.:
>>> DATA
<<< 550-Verification failed for <apache@localhost.localdomain>
<<< 550-Unrouteable address
<<< 550 Sender verify failed
550 5.1.1 <someone@a.real.address.com>... User unknown
<<< 503 valid RCPT command must precede DATA
[-- Attachment #2 --]
[-- Type: message/delivery-status, Encoding: 7bit, Size: 0.4K --]
Reporting-MTA: dns; localhost.localdomain
Received-From-MTA: DNS; ArthurDent
Arrival-Date: Mon, 3 Jul 2006 17:35:33 +0100
Final-Recipient: RFC822; someone@a.real.address.com
Action: failed
Status: 5.1.1
Remote-MTA: DNS; punt-1.mail.demon.net
Diagnostic-Code: SMTP; 550-Verification failed for <apache@localhost.localdomain>
Last-Attempt-Date: Mon, 3 Jul 2006 17:35:35 +0100
If I replace "someone@a.real.address.com" with "myusername@localhost.localdomain" the mail finds its way into my user's mail spool.
I have Googled without much success. The closest I have come to a solution was reading somewhere that I should have something in my /etc/mail/local-host-names file so I have tried both "localhost.localdomain" and "apache@localhost.localdomain" (there is no example of what form the entry should take) and in any case - it didn't work (I did re-start Apache before I tried again...)
Is it a sendmail problem? Is it a PHP problem? Is it an Apache problem?
Can anyone guide me through this?
Many thanks to all...
Mark