Getting PHP to read an e-mail

This is a discussion on Getting PHP to read an e-mail within the PHP Language forums, part of the PHP Programming Forums category; Ok, for the reference, I'm using PHP 4.3, mySQL and sendmail. I have a news content site, and ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-15-2003
Rob
 
Posts: n/a
Default Getting PHP to read an e-mail

Ok, for the reference, I'm using PHP 4.3, mySQL and sendmail.

I have a news content site, and I have an e-mail address dedicated for PHP
content automation.

What I'm aiming to do here is have PHP grab the e-mail, parse it, and update
the database.

Parsing and updating the database is no prob. I'm a little clueless on how
to get PHP to grab e-mails.

I don't need to be hand-held through it, but if anyone knows reference
locations (articles, PHP documentation entries, theory, etc), it would be a
big help.




Thanks in Advance,

Robert


Reply With Quote
  #2 (permalink)  
Old 10-15-2003
Ian P. Christian
 
Posts: n/a
Default Re: Getting PHP to read an e-mail

Rob wrote:

> Ok, for the reference, I'm using PHP 4.3, mySQL and sendmail.
>
> I have a news content site, and I have an e-mail address dedicated for PHP
> content automation.
>
> What I'm aiming to do here is have PHP grab the e-mail, parse it, and
> update the database.
>
> Parsing and updating the database is no prob. I'm a little clueless on
> how to get PHP to grab e-mails.


A .forward file can be used to pass a file to a pipe.

Ian P. Christian

Reply With Quote
  #3 (permalink)  
Old 10-16-2003
Alan Little
 
Posts: n/a
Default Re: Getting PHP to read an e-mail

Carved in mystic runes upon the very living rock, the last words of Rob
of comp.lang.php make plain:

> I don't need to be hand-held through it, but if anyone knows reference
> locations (articles, PHP documentation entries, theory, etc), it would
> be a big help.


Well, I can't really give you any references, but I can tell you what
I've learned from experience, as I have quite a number of scripts
operating this way.

First configure your email system to pipe the email to a PHP script. If
you don't know how to do that, you'll have to ask someone familiar with
your particular system and configuration.

The PHP script will need to have a shebang line pointing to the PHP
interpreter, for example:

#!/usr/bin/php -q

as the very first line in the file before the <?php

Then just open /dev/stdin:

$fh = fopen("/dev/stdin", "r");

and read the email from it. Depending on your system setup, there may be
some useful environment and server variables available that can save you
some digging and parsing, so I'd suggest dumping those arrays out to a
file to see what's there.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Reply With Quote
  #4 (permalink)  
Old 10-16-2003
Nikolai Chuvakhin
 
Posts: n/a
Default Re: Getting PHP to read an e-mail

"Rob" <robertkaranfilian@sbcglobal.net> wrote in message
news:<3Pdjb.52$fF.14346451@newssvr21.news.prodigy. com>...
>
> I have a news content site, and I have an e-mail address dedicated for PHP
> content automation.
>
> What I'm aiming to do here is have PHP grab the e-mail, parse it, and update
> the database.
>
> Parsing and updating the database is no prob. I'm a little clueless on how
> to get PHP to grab e-mails.


You have two options:

1. Implement something based on PHP's built-in IMAP functions:

http://www.php.net/imap

Note that I say IMAP, but these functions are equally capable
of working with POP3 and local mailboxes.

2. Go to phpclasses.org and search for a keyword "POP3". There
are a couple of classes there that do not rely on PHP's IMAP
functions (not all hosting services have them enabled), but
implement access to a remote POP3 server directly using the
sockets mechanism.

Cheers,
NC
Reply With Quote
  #5 (permalink)  
Old 10-16-2003
K_Lee
 
Posts: n/a
Default Re: Getting PHP to read an e-mail

nc@iname.com (Nikolai Chuvakhin) wrote in message news:<32d7a63c.0310151950.467510dc@posting.google. com>...
> "Rob" <robertkaranfilian@sbcglobal.net> wrote in message
> news:<3Pdjb.52$fF.14346451@newssvr21.news.prodigy. com>...
> >
> > I have a news content site, and I have an e-mail address dedicated for PHP
> > content automation.
> >
> > What I'm aiming to do here is have PHP grab the e-mail, parse it, and update
> > the database.
> >
> > Parsing and updating the database is no prob. I'm a little clueless on how
> > to get PHP to grab e-mails.

>
> You have two options:
>
> 1. Implement something based on PHP's built-in IMAP functions:
>
> http://www.php.net/imap
>
> Note that I say IMAP, but these functions are equally capable
> of working with POP3 and local mailboxes.
>
> 2. Go to phpclasses.org and search for a keyword "POP3". There
> are a couple of classes there that do not rely on PHP's IMAP
> functions (not all hosting services have them enabled), but
> implement access to a remote POP3 server directly using the
> sockets mechanism.
>
> Cheers,
> NC


Third options: check out squirrelmail.
http://www.squirrelmail.org/

It works very well for me.

--
The source is out there. Browse and document open/share source
projects such as Apache, Tcl, PHP, EtherReal, Mozilla, .Net SSCLI at
http://www.slink-software.com/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting 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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:39 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0