LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-03-2006, 12:36 PM   #1
ArthurDent
Member
 
Registered: Feb 2004
Location: London
Distribution: Fedora Core 5, Mandrake 10.0, Gentoo, Suse
Posts: 179

Rep: Reputation: 30
PHP + Sendmail problem


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
 
Old 07-03-2006, 01:49 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
It looks to me like the recipient's e-mail server rejected the message because it's from an obviously bogus e-mail address (apache@localhost.localdomain). You should give your machine a valid host name if you want to do this for real (if you've not got a static IP dyndns or no-ip can help).

Also, it's much simpler to use PHP's in-built mail function for this. IIRC you can use this to set the From address to whatever you want, so mnaybe you won't have to bother with the host name. Be advised, though, some mail servers flag messages with host names that don't match the originating server as spam, though.
 
Old 07-03-2006, 02:17 PM   #3
ArthurDent
Member
 
Registered: Feb 2004
Location: London
Distribution: Fedora Core 5, Mandrake 10.0, Gentoo, Suse
Posts: 179

Original Poster
Rep: Reputation: 30
Quote:
It looks to me like the recipient's e-mail server rejected the message because it's from an obviously bogus e-mail address (apache@localhost.localdomain).
Well the recipient is me. I've checked the headers and I don't think the message even gets close to getting out into the big wide world. It gets rejected before it goes to my ISP (I think).
Quote:
You should give your machine a valid host name if you want to do this for real (if you've not got a static IP dyndns or no-ip can help).
How do I do this. I don't (yet) have a real web address and so my machine is named (ahem) ArthurDent.

However. I do think you are on to something here because when I restart Apche I get the following error:
Code:
[root@ArthurDent ~]# /sbin/service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]
[root@ArthurDent ~]#
How do I go about fixing this?

Thanks again...

Mark
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Mail() Problem w/ Sendmail jusme Linux - Software 6 08-18-2012 02:35 PM
problem with my sendmail and php nshoboul Linux - Networking 3 04-23-2007 02:25 AM
problem with sendmail and php nshoboul Linux - Software 0 12-19-2003 08:06 AM
Apache, PHP or SendMail problem ?? dddlc Linux - Software 3 04-28-2003 07:13 AM
sendmail - PHP problem munkus Linux - General 0 02-22-2003 05:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration