Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger a PHP script based on incoming email?

Status
Not open for further replies.

awaresoft

Programmer
Feb 16, 2002
373
DE
Anyone know if its possible to trigger a PHP script when a specific email account receives an email? I'm sure this is possible as this must be how auto-responder software is written?

I have a process that submits a file (via email) to another service and gets a text email back containing a URL to the converted version of the file. I would like my script to grab that URL and retrieve the file it points to.

Clear as mud?

Open to ideas.

Thanks,
Malcolm
 
I would recommend to have a CRON job running which checks the mail for the specific account. PHP has IMAP functions - which in spite of the naming also work for POP3.
You would need:
1. A cron tab for the job
2. PHP command line capability to trigger the script by the cron job (there's a workaraound)
3. The script which checks the mail, analyzes it and retrieves the file from the URL

Not too difficult.
 
DRJ478,

Thanks for your follow-up. Can you elaborate on point 2, specifically your comment "there's a workaround"?

Is there a specific syntax I need to use to invoke PHP from the command line, using CRON, in a LunarPages environment?

I'm under the impression that I can have an incoming email directly trigger a script so that I don't need to poll a POP3/IMAP account via CRON. Does this ring a bell with anyone?

If so, how do I configure my mail system to trigger script(s) for a specific mailbox account. Can I do the same for an FTP account?

Thanks,
Malcolm
 
You are probably talking about procmail - used to filter mail and can also trigger a script. Read up on procmail.
Ask the lunarpages guys if they have PHP available as a command line version.
FTP: That depends on the ftp server software.
 
DRJ478,

Thanks for your help! I'm off to find answers to your questions.

Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top