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:
$fd = popen("/usr/sbin/sendmail -t","w");
fputs($fd, "To: email@example.com\n");
fputs($fd, "From: Me \n");
fputs($fd, "Subject: Test message from my web site\n");
fputs($fd, "X-Mailer: PHP3\n");
When I run it it fails with the following error:
Date: Mon, 3 Jul 2006 17:35:35 +0100
From: Mail Delivery Subsystem <MAILER-DAEMON@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 -----
(reason: 550-Verification failed for <firstname.lastname@example.org>)
----- Transcript of session follows -----
... while talking to punt-1.mail.demon.net.:
<<< 550-Verification failed for <email@example.com>
<<< 550-Unrouteable address
<<< 550 Sender verify failed
550 5.1.1 <firstname.lastname@example.org>... 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; email@example.com
Remote-MTA: DNS; punt-1.mail.demon.net
Diagnostic-Code: SMTP; 550-Verification failed for <firstname.lastname@example.org>
Last-Attempt-Date: Mon, 3 Jul 2006 17:35:35 +0100
If I replace "email@example.com" with "firstname.lastname@example.org" 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 "email@example.com" (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...