IBM developerWorks
           Server Administration
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesServer Administration

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old November 30th, 2005, 08:05 PM
Andrew's Avatar
Andrew Andrew is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,935 Andrew User rank is Private First Class (20 - 50 Reputation Level)Andrew User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 2429 Folding Title: Novice Folder
Time spent in forums: 4 Days 1 h 52 m 57 sec
Reputation Power: 3
Orkut
Email Piping anyone?

Well im making my first post on CW in quite a long time, (exams etc). So anyway recently ive been working with email piping, trying to get a script to post content to my site from email.

So here is how i have the setup....

using Cpanel to forward the email to the script using:

Code:
|/home/andrew/public_html/postmaster.php


Now the problem is that the script process's it fine, but then i get a mail delivery error back from my server even though the script works just fine. Below is a copy of the error email i get.

(I dont need reminding that im still on PHP4 here, site isnt ready for PHP5 yet)

Code:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  pipe to |/home/andrew/public_html/postmaster.php
    generated by xxxxxxxxxxxxxx@blog.mydomain.com

The following text was generated during the delivery attempt:

------ pipe to |/home/andrew/public_html/postmaster.php
       generated by xxxxxxxxxxxxxx@blog.mydomain.com ------

Content-type: text/html
X-Powered-By: PHP/4.4.0


------ This is a copy of the message, including all the headers. ------

Return-path: <xxxxxxxxxx@mydomain.com>
Received: from [86.138.76.43] (helo=[86.138.76.43])
	by myserver.mydomain.com with esmtpa (Exim 4.52)
	id 1EhYsA-0006AY-Jw
	for xxxxxxx@blog.mydomain.com; Wed, 30 Nov 2005 20:48:15 +0000
Message-ID: <438E1015.50106@mydomain.com>
Disposition-Notification-To: Andy Walsh <xxxxxxx@mydomain.com>
Date: Wed, 30 Nov 2005 20:48:21 +0000
From: Andy Walsh <xxxxxxx@mydomain.com>
User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To:  xxxxxxx@blog.mydomain.com
Subject: Testing
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Blah blah blah, my testing message.....




Here is the php i found after googling....

php Code:
Original - php Code
  1.  
  2.  
  3. #!/usr/bin/php
  4. <?php
  5.  
  6. // read from stdin
  7. $fd = fopen("php://stdin", "r");
  8. $email = "";
  9. while (!feof($fd)) {
  10.     $email .= fread($fd, 1024);
  11. }
  12. fclose($fd);
  13.  
  14.  
  15. //Log emails
  16.  
  17. $outFile = fopen("/home/andrew/public_html/emails.txt","w");
  18. fwrite($outFile,$email);
  19. fclose($outFile);
  20.  
  21. /* This is here to prove that emails are being received! */
  22.  
  23. mail("me@mydomain.com","RECEIVED MAIL!","I got the blog mail you sent me","From: script@mydomain.com");
  24. ?>
  25.  


So my question is, why is it still returning this error message even though the script runs fine? Worse still it doesnt even say what is wrong....

Any help would be appreciated


Andrew

Reply With Quote
  #2  
Old November 30th, 2005, 08:13 PM
Andrew's Avatar
Andrew Andrew is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,935 Andrew User rank is Private First Class (20 - 50 Reputation Level)Andrew User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 2429 Folding Title: Novice Folder
Time spent in forums: 4 Days 1 h 52 m 57 sec
Reputation Power: 3
Orkut
RE: Email Piping anyone?

probably should of put this in Server Admin forum, but it could equally be a php problem. Ah ill just move it to server as it is unlikely to be php.

Reply With Quote
  #3  
Old November 30th, 2005, 08:13 PM
System System is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 665 System User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Message Moved

Thread moved from 'PHP Coding' to 'Server Administration' by Andrew.

Reason:

Reply With Quote
  #4  
Old December 2nd, 2005, 09:29 PM
Andrew's Avatar
Andrew Andrew is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,935 Andrew User rank is Private First Class (20 - 50 Reputation Level)Andrew User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 2429 Folding Title: Novice Folder
Time spent in forums: 4 Days 1 h 52 m 57 sec
Reputation Power: 3
Orkut
RE: Email Piping anyone?

Right it doesnt seem to be my script, ive checked all the things i can think of. If its any help im using Sendmail/Exim on a cpanel server (only have cpanel for friends of mine who have sites on my server)

Reply With Quote
  #5  
Old February 24th, 2006, 01:14 PM
danthonyjr danthonyjr is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 danthonyjr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Email Piping anyone?

Hi, sorry for the late chime in...just found this thread.

I think the problem is here:
#!/usr/bin/php

Your path to php is probably '/usr/local/bin/php' try replacing that in the script and you won't get the errors.

Reply With Quote
  #6  
Old July 26th, 2006, 06:29 PM
leftyscissorz leftyscissorz is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 leftyscissorz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Email Piping anyone?

EDIT: Never mind, problem solved. For future reerence for anyone else who's a knucklehead like me, use "#!/usr/bin/php -q" instead of "#!/usr/bin/php" (sans quotes).

I seem to be having a problem. Everything does what it's supposed to, but I get an error message anyway:
php Code:
Original - php Code
  1.  
  2. This message was created automatically by mail delivery software.
  3.  
  4. A message that you sent could not be delivered to one or more of its
  5. recipients. This is a permanent error. The following address(es) failed:
  6.  
  7.   pipe to |/home/ebrs/mail2shoutbox.php
  8.     generated by XXXXXX@ebrs.org
  9.  
  10. The following text was generated during the delivery attempt:
  11.  
  12. ------ pipe to |/home/ebrs/mail2shoutbox.php
  13.        generated by XXXXXX@ebrs.org ------
  14.  
  15. X-Powered-By: PHP/4.4.2
  16. Content-type: text/html
  17.  
  18.  
  19. ------ This is a copy of the message, including all the headers. ------
  20.  
  21. Return-path: <XXXXXX@members.ebrs.org>
  22. Received: from ool-4354093b.dyn.optonline.net ([67.84.9.59]:4907 helo=[192.168.1.101])
  23.     by spider.nghsecure.com with esmtpsa (TLSv1:AES256-SHA:256)
  24.     (Exim 4.52)
  25.     id 1G5ose-0000Z6-H3
  26.     for XXXXXX@ebrs.org; Wed, 26 Jul 2006 15:17:16 -0400
  27. Message-ID: <44C7BFB2.5070305@members.ebrs.org>
  28. Date: Wed, 26 Jul 2006 15:17:06 -0400
  29. From: Matthew Redding <XXXXXX@members.ebrs.org>
  30. User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
  31. X-Accept-Language: en-us, en
  32. MIME-Version: 1.0
  33. To:  shoutbox@ebrs.org
  34. Subject: Test message
  35. Content-Type: text/plain; charset=ISO-8859-1; format=flowed
  36. Content-Transfer-Encoding: 7bit
  37. X-Antivirus-Scanner: Clean mail though you should still use an Antivirus
  38.  
  39. Testing.


The script is as follows:
php Code:
Original - php Code
  1.  
  2. #!/usr/bin/php
  3. <?php
  4. // read from stdin
  5. $fd = fopen("php://stdin", "r");
  6. $email = "";
  7. while (!feof($fd)) {
  8.     $email .= fread($fd, 1024);
  9. }
  10. fclose($fd);
  11.  
  12. // handle email
  13. $lines = explode("n", $email);
  14.  
  15. // empty vars
  16. $from = "";
  17. $subject = "";
  18. $headers = "";
  19. $message = "";
  20. $splittingheaders = true;
  21.  
  22. for ($i=0; $i<count($lines); $i++) {
  23.     if ($splittingheaders) {
  24.         // this is a header
  25.         $headers .= $lines[$i]."n";
  26.  
  27.         // look out for special headers
  28.         if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
  29.             $subject = $matches[1];
  30.         }
  31.         if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
  32.             $from = $matches[1];
  33.         }
  34.     } else {
  35.         // not a header, but message
  36.         $message .= $lines[$i]."n";
  37.     }
  38.  
  39.     if (trim($lines[$i])=="") {
  40.         // empty line, header section has ended
  41.         $splittingheaders = false;
  42.     }
  43. }
  44.  
  45. // Send to database
  46. $username = "user";
  47. $password = "pass";
  48. $database = "test";
  49. $server   = "mysql.server.com";
  50. $time = date("jS F Y");
  51. $query    = "INSERT INTO shoutbox(id,name,message,time, time_time)VALUES('NULL','ebrescue','<br>$subject<br><$from><br>$message','$time', ".time().")";
  52.  
  53. mysql_connect($server,$username,$password);
  54. @mysql_select_db($database) or die( "Unable to select database");
  55. mysql_query($query);
  56.  
  57. //For Testing Purposes
  58. mail("XXXXX@members.ebrs.org", $subject, $message);
  59.  
  60. ?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesServer Administration > Email Piping anyone?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump