Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Accessing a POP server with PHP

Accessing a POP server with PHP
Thread Tools
l008com
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Mar 12, 2011, 06:42 AM
 
I need a way to access a POP server from a PHP script. But there's a catch.

So PHP has it's own IMAP functions (which include POP). But you have to compile them in with c-client. This won't work for me because I'm running OS X Server. Software updates will repeatedly break my scripts. Anything that needs a custom compiled PHP, won't work. (this server lives 2000 miles away in a data center. maybe my next server will be a simple OS X install, with the good stuff installed with MacPorts. But this server's setup isn't going to change).

Then there's the pear IMAP class for PHP. But again this won't work. This is going to be a high volume script, so I need to stick with POP. The pear class only works with IMAP.

So I'm looking for a third solution.
The basic job I'm looking to accomplish is this: I want to make a script that periodically connects to a PHP server, downloads each email on the server one at a time, parses each email and adds the relevant data to an SQL table.
Ideally, I'd also like control over multi-part messages, so I could "get" just the text portion of multi-part messages, without having to dig through the email contents myself.

So what I'm really looking for, is the POP version of CURL. A simple application I can access within my script, and get the data I want automatically returned to me. In an ideally world, I'd like this command line pop mail client to be a single self contained binary file, that could follow my site from server to server. But really, anything will work as long as it's not something that will get overwritten or broken when I run OS X software updates.

So what do you think?

     
Rainy Day
Grizzled Veteran
Join Date: Nov 2001
Location: Oregon
Status: Offline
Reply With Quote
Apr 17, 2011, 06:17 AM
 
Originally Posted by l008com View Post
So what I'm really looking for, is the POP version of CURL.
Have you looked at FetchMail?
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Apr 17, 2011, 07:07 AM
 
Yeah, that doesn't seem to do what I'm looking for.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Apr 17, 2011, 01:53 PM
 
Originally Posted by l008com View Post
Yeah, that doesn't seem to do what I'm looking for.

Why not? It could be used within a cronjob.

Why not setup a mail gateway instead of involving POP? I don't understand why you need POP. Just have the mail sent to your server, and include an entry in your /etc/aliases to pipe the mail to your script that does all the parsing and filing.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Apr 17, 2011, 01:54 PM
 
i.e., in your /etc/aliases:

aliasusername: "|/path/to/your/script"
     
   
Thread Tools
 
Forum Links
Forum 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 On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 01:15 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,