P.Z. Low Cost CPanel Web Hosting  

Go Back   P.Z. Low Cost CPanel Web Hosting > Page-Zone Web Hosting Main Forum > General FAQ > General Questions and Comments

General Questions and Comments Post your question or grace us with your knowledge. Posting limited to registered members.

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Forwarding mail to a Php script
Old
  (#1 (permalink))
ldesign
Registered User
ldesign is on a distinguished road
 
ldesign's Avatar
 
Status: Offline
Posts: 251
Join Date: Feb 2004
Location: Colorado
Rep Power: 42
Forwarding mail to a Php script - 03-11-2004, 02:13 PM

I've started a mailing list that I wrote in Php. I would like to confirm new members (subscribers) via two methods:

1. Send an email with a link (with unique inputs) to a script that confirms their subscription.

2. Allow them to simply respond to the same email. The subject line will have the unique confirmation id, as well.

For No. 2, I want to respond immediately, so I'd like mail coming to a particular mailbox to be forwarded to a script for processing when it arrives.

Is that possible? And if so, how?

(I've read of shell access allowing me a .forward file, but is their another way to do it without having shell access? My UNIX skills are rather dated.)

Chuck
   
Reply With Quote
Re: Forwarding mail to a Php script
Old
  (#2 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 802
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 78
Re: Forwarding mail to a Php script - 03-12-2004, 12:16 PM

Quote:
For No. 2, I want to respond immediately, so I'd like mail coming to a particular mailbox to be forwarded to a script for processing when it arrives.

Is that possible? And if so, how?
The mailbox is just a folder, the messages it contains are a text file. check the box every few minutes with a cron job and when it has something in it grab it and put it in a temp folder, clean the mail box, parse the temp, pull the Subject:ID#####(might be more than one) and have the job do what it needs to do or hand it off to another script to finish.


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Old
  (#3 (permalink))
ldesign
Registered User
ldesign is on a distinguished road
 
ldesign's Avatar
 
Status: Offline
Posts: 251
Join Date: Feb 2004
Location: Colorado
Rep Power: 42
07-22-2005, 11:27 PM

What do you know. I searched this topic because I'm still interesting in doing this sort of thing. So I find my own post .... and a year and a half later I'm still wondering ... rather than pool the Pop3 mailbox with a cron job, I'd rather use a .forward file to forward email sent to "some address" to be processed by a Php script.

It appears that all I need to do is put a .forward file in /home/username/etc

The question is: what do I put in the .forward file?

(And is this really the correct file and location for doing such a thing?)
   
Reply With Quote
maybe try procmail
Old
  (#4 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 802
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 78
maybe try procmail - 07-23-2005, 12:20 PM

.foreward is greedy. Try making a file, .procmailrc containing this

:0 H
* ^To:.*this_address.com
! forwarded@address.com

this file should go in your root, this is not your html root but one folder above public_html.

ps. its a zero, not a cap oh.


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Old
  (#5 (permalink))
ldesign
Registered User
ldesign is on a distinguished road
 
ldesign's Avatar
 
Status: Offline
Posts: 251
Join Date: Feb 2004
Location: Colorado
Rep Power: 42
07-23-2005, 06:19 PM

Thanks for the help.

I put a file called .procmailrc in my root folder (as you said - in the folder that contains public_html).

I used the format you specified (zero not oh) and mail is simply not forwarded.
I even tried variations based on some Google searches, but still no luck.

I've tried every variation I've seen in my searching (even tried adding a .forward file with "|/usr/bin/procmail") and I get nothing.

I wonder if it's something at Page Zone.

Thanks,
Chuck
   
Reply With Quote
Old
  (#6 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 802
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 78
07-23-2005, 07:24 PM

procmail is a mail processor that uses .procmailrc, .forward is a file used by the mail software. The order is .forward then .procmailrc, is either of these are present then they are acted upon. Thats my experience. You might have to ask support for some help.

The format for a .forward file is simple, forward_to@address.com

just a thought. I know the .forward file MUST have a return for a line ending, procmail might also require this.


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Old
  (#7 (permalink))
Jim
of Page-Zone
Jim will become famous soon enoughJim will become famous soon enough
 
Status: Offline
Posts: 1,131
Join Date: Jun 2002
Location: Wauseon, Ohio
Rep Power: 98
My location
07-23-2005, 07:36 PM

No your all wrong

If you want to pipe an email to a php script using a cpanel based server create a plain text file and call it aliases (no extention). Put the pertinant info into that file. I'll show a working example:

support: |/home/user/public_html/helpdesk/email_support.pl

********
Upload the file to etc in the root of your account (/home/user/etc)
Any email sent to support@yourdomain will get piped to email_support.pl for processing.


--
Thank You,
Jim Snape
Page-Zone
--
   
Reply With Quote
Old
  (#8 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 802
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 78
07-23-2005, 09:23 PM

So because of cpanel we dont have procmail?


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Old
  (#9 (permalink))
Jim
of Page-Zone
Jim will become famous soon enoughJim will become famous soon enough
 
Status: Offline
Posts: 1,131
Join Date: Jun 2002
Location: Wauseon, Ohio
Rep Power: 98
My location
07-23-2005, 11:05 PM

We could probably make some modifications to the exim.conf file to get procmail working with it but the Exim config file gets replaced automatically without warning from time to time. Creating the aliases file has always worked for me but there are usually about 3 ways to do something. The .forward --> procmail way might work, I haven't done it that way but it is probably possible to do if you know the exact syntax.

edit: Just kidding about the "your all wrong" statement


--
Thank You,
Jim Snape
Page-Zone
--
   
Reply With Quote
Old
  (#10 (permalink))
ldesign
Registered User
ldesign is on a distinguished road
 
ldesign's Avatar
 
Status: Offline
Posts: 251
Join Date: Feb 2004
Location: Colorado
Rep Power: 42
07-23-2005, 11:58 PM

I missed your reply earlier, Jim .... thanks.

Unhappily, though, it does not work for me.

I created a plain text file called aliases (no extension), just as you said.

That file contains the line:
emailid: |/home/myusername/public_html/myscript.php

I uploaded the file (aliases) to /home/myusername/etc

The script, myscript.php (not its real name), sends a short email to my main email account (at my ISP) - just for testing.

If I send an email to emailid at mydomain (where the aliases file is), I do not get the email the script should send. I can see the emails arrive in my mailbox at mydomain, so I know they are getting there.

If I merely enter the URL - mydomain.com/myscript.php in my browser, I do get the test email.

What could be wrong?

Chuck
   
Reply With Quote
Old
  (#11 (permalink))
Jim
of Page-Zone
Jim will become famous soon enoughJim will become famous soon enough
 
Status: Offline
Posts: 1,131
Join Date: Jun 2002
Location: Wauseon, Ohio
Rep Power: 98
My location
07-24-2005, 12:11 AM

Try making a forwarder in Cpanel but put this in the address to forward to section:

|/home/myusername/public_html/myscript.php


--
Thank You,
Jim Snape
Page-Zone
--
   
Reply With Quote
Old
  (#12 (permalink))
ldesign
Registered User
ldesign is on a distinguished road
 
ldesign's Avatar
 
Status: Offline
Posts: 251
Join Date: Feb 2004
Location: Colorado
Rep Power: 42
07-24-2005, 12:25 AM

Tried that. No workie.

I got a mail delivery failure:

----------------------
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/myusername/public_html/myscript.php
generated by emailid@mydomain.com
local delivery failed
----------------------

I then tried removing the | but then nothing happened.

Chuck
   
Reply With Quote
Old
  (#13 (permalink))
Jim
of Page-Zone
Jim will become famous soon enoughJim will become famous soon enough
 
Status: Offline
Posts: 1,131
Join Date: Jun 2002
Location: Wauseon, Ohio
Rep Power: 98
My location
07-24-2005, 12:43 AM

OK, then try this:

|/usr/bin/php -q /home/myusername/public_html/myscript.php


--
Thank You,
Jim Snape
Page-Zone
--
   
Reply With Quote
Old
  (#14 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 802
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 78
07-24-2005, 01:01 AM

No need ot edit anything. I prefer grabbing the mail file, I know that is going to work.


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote