icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » Email » Forwarding/Piping emails to a PHP Program

Email General questions, webmail, mailing lists.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old November 15th, 2007, 6:28 PM   #1 (permalink)
Registered User
Seasoned Poster
 
Joined in May 2003
Lives in Atlanta, GA
69 posts
Gave thanks: 0
Thanked 1 Time in 1 Post
Question Forwarding/Piping emails to a PHP Program

So here's the deal.
I *just* stumbled across this feature/setting in cPanel:

Cpanel -> Email Forwarder -> Destination: Pipe to a Program

and it COULD be exactly what I have been looking for a long time!

Well, so, if I wanted to forward/pipe the emails to a specific PHP script... HOW do I handle the email? i.e., it probably isn't a $_GET or $_POST since it's not HTTP. In what format does the email get piped into the PHP script, and how would I parse it? Also, what about an email that has an attachment? How can that be handled by the PHP script?

ANY thoughts/ideas on how this works would be HIGHLY appreciated! Thanks!!

-taka
__________________
Server:
simplemedia.com
XX.XX.74.115 (Reseller)
DNS:
ns770.dizinc.com
ns771.dizinc.com
Sites:
www.simplemedia.com
www.southernbloom.com
www.torimoto.net
www.rubyforest.net
takabanana is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 15th, 2007, 6:58 PM   #2 (permalink)
Registered User
Seasoned Poster
 
Joined in May 2003
Lives in Atlanta, GA
69 posts
Gave thanks: 0
Thanked 1 Time in 1 Post
ok so I found out (thanks to Google) that it's just STDIN.

But what is the formatting of the mail? I am currently assuming pure text like POP/SMTP uses...
__________________
Server:
simplemedia.com
XX.XX.74.115 (Reseller)
DNS:
ns770.dizinc.com
ns771.dizinc.com
Sites:
www.simplemedia.com
www.southernbloom.com
www.torimoto.net
www.rubyforest.net
takabanana is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 15th, 2007, 7:43 PM   #3 (permalink)
Registered User
Seasoned Poster
 
Joined in May 2003
Lives in Atlanta, GA
69 posts
Gave thanks: 0
Thanked 1 Time in 1 Post
i'm just answering my own Q's... :-)
ok so it's just normal internet mail format (ASCII text).

I've got it mostly working - only issue I have is that the PHP file DOES parse it, because I have the PHP file itself do a mail() to forward all content from STDIN to myself (which does work)... but I ALSO get an error email from the server:

Quote:
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 |<PHP path/filename>
generated by <Forwarded email address>

The following text was generated during the delivery attempt:

------ pipe to |<PHP path/filename>
generated by <Forwarded email address> ------

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


------ This is a copy of the message, including all the headers. ------
Any thoughts from anyone?
__________________
Server:
simplemedia.com
XX.XX.74.115 (Reseller)
DNS:
ns770.dizinc.com
ns771.dizinc.com
Sites:
www.simplemedia.com
www.southernbloom.com
www.torimoto.net
www.rubyforest.net

Last edited by takabanana; November 15th, 2007 at 7:44 PM..
takabanana is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On