I will probably use a hyperlink with a unique ID, but I also want to
know how to go about reading from a mailbox with Php so I can use an
email reply method, too.
I'm having trouble finding any kind of tutorial. From the bit of
searching I've done, it appears I need to use an IMAP client and the
IMAP functions (I've no experience with using IMAP, but could learn).
Can I use Php functions to read email from a POP3 mailbox?
Does anyone know of any tutorials or helpful web sites that might
explain what I need to do?
Thanks in Advance.
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
1. forward file <http://groups.google.com/groups?selm=vppnnssuq4p394%40corp.supernews.com>
2. <http://in2.php.net/imap> Manual & user notes
--
"I don't believe in the God who doesn't give me food, but shows me
heaven!"--Swami Vivekanandha
Email: rrjanbiah-at-Y!com
>Chuck Anderson <website...@seemy.sig> wrote in message news:<cnn3c.529026$na.1267192@attbi_s04>...
>> Can anyone point me in the right direction? I want to use Php to
>> automate confirmation of someone joining an email list by them replying
>> to an email (so they don't have to have a browser?).
>>
>> I will probably use a hyperlink with a unique ID, but I also want to
>> know how to go about reading from a mailbox with Php so I can use an
>> email reply method, too.
>>
>> I'm having trouble finding any kind of tutorial. From the bit of
>> searching I've done, it appears I need to use an IMAP client and the
>> IMAP functions (I've no experience with using IMAP, but could learn).
>>
>> Can I use Php functions to read email from a POP3 mailbox?
>>
>> Does anyone know of any tutorials or helpful web sites that might
>> explain what I need to do?
>
> 1. forward file <http://groups.google.com/groups?selm=vppnnssuq4p394%40corp.supernews.com>
> 2. <http://in2.php.net/imap> Manual & user notes
>
>
>
I see. I can use the "IMAP" functions for POP3. Thanks for the pointer.
I can begin experimenting now.
(The first link is how I can have a new email trigger the event. That
will also be most useful.)
If so, differnt aproach than trying to pop a box.
Also if you are using, say redhat linux:
in /etc/aliases file add this line:
alias-phpparse: "| /etc/smrsh/phpparser.php"
then in /etc/smrsh/ create a script called phpparser.php and it should look
like this:
(make sure the #!/.... is the very first line!)
#!/usr/bin/php -q
<?php
// read from stdin
$fd = fopen("php://stdin", "r");
// we read each line of the incoming email
while (!feof($fd))
{
$inData = fgets($fd, 1024);
$inData = trim($inData);
// we loop over and over untill we read each line
// proccess email here, $inData will contain 1 line from the email
on each pass
}
fclose($fd);
?>
--
Mike Bradley
http://www.gzentools.com -- free online php tools
"Chuck Anderson" <website...@seemy.sig> wrote in message
news:cnn3c.529026$na.1267192@attbi_s04...
an...@yourdomain.com alais-phpparser
then rebuild the map with
cd /etc/mail
makemap hash virtusertable < virtusertable
--
Mike Bradley
http://www.gzentools.com -- free online php tools
"CountScubula" <m...@scantek.hotmail.com> wrote in message
news:H444c.22905$F15...@newssvr29.news.prodigy.com...
> > Chuck Anderson . Boulder, CO
>Let me ask this, Are you trying to have PHP parse an email when it arrives?
>
>
That's what I'd like to do.
>If so, differnt aproach than trying to pop a box.
>
>
I assume you are talking about having new a new email trigger an event
(parse the email), and that I could still do the same manually or with a
task scheduler using IMAP functions.
Yes?
>Also if you are using, say redhat linux:
>
>
My site is on a Linux server, but I don't even have shell access. I'll
keep your suggestion, though, because I *can* get shell access. It
sounds like what I want to do is no simple thing (at least for me).
>in /etc/aliases file add this line:
>
>alias-phpparse: "| /etc/smrsh/phpparser.php"
>
>
>then in /etc/smrsh/ create a script called phpparser.php and it should look
>like this:
>(make sure the #!/.... is the very first line!)\
>
>
Gotcha - tells the php "interpreter" to read the following lines.
>#!/usr/bin/php -q
><?php
> // read from stdin
> $fd = fopen("php://stdin", "r");
>
> // we read each line of the incoming email
> while (!feof($fd))
> {
> $inData = fgets($fd, 1024);
> $inData = trim($inData);
>
> // we loop over and over untill we read each line
> // proccess email here, $inData will contain 1 line from the email
>on each pass
>
>
> }
> fclose($fd);
>?>
>
>
>
That added line in your next post is quite key to understanding how this
works, right?
"an...@yourdomain.com alias-phpparser"
Thanks for the help.
This is a way to have an email, upon arrival, get passed to your php script
instead of proccessed and put into a mailbox. if you wish to save a copy or
have it end up in the correct mailbox, then you need to do that yourself.
This is good for autoreplies, or email request systems (like fax back)
this part
> add line to /etc/mail/virtusertable
>an...@yourdomain.com alias-phpparser
>
>then rebuild the map with
>cd /etc/mail
>makemap hash virtusertable < virtusertable
adds an email address to the mail server, so anything comming to that email
address would go to user alias-phpparser (since this file only maps email
address to user accounts we map to an alias user)
here we add the alias user, in, well /etc/alias file, this file allows alias
user accounts, these can map to other users, single or more, or can forward
mail to a script. generaly the scripts sit in /etc/smrsh
>so in /etc/alias file we add the line
>alias-phpparser: "| /etc/smrsh/phpparser.php"
this tells the box the alias-phpparser is an alias, and to filter the mail
to the script
then in /etc/smrsh/ we put scripts that get passed emails from sendmail,
smrsh is SendMail Retricted SHell, this should be the only dir that sendmail
should be allowed to run scripts.
>so, in /etc/smrsh/ dir we add the script
>alias-phpparser.php
>also this file needs to be chmod 755
#!/usr/bin/php -q
<?php
// read from stdin
$fd = fopen("php://stdin", "r");
// we read each line of the incoming email
while (!feof($fd))
{
$inData = fgets($fd, 1024);
$inData = trim($inData);
// we loop over and over untill we read each line
// proccess email here, $inData will contain 1 line from the email
on each pass
}
fclose($fd);
?>
--
Mike Bradley
http://www.gzentools.com -- free online php tools
"Chuck Anderson" <website...@seemy.sig> wrote in message
news:f584c.10276$i76.158609@attbi_s03...
>I guess I should have exmplained how it works.
>
>This is a way to have an email, upon arrival, get passed to your php script
>instead of proccessed and put into a mailbox.
>
That *is* what I ultimately want to do.
>This is good for autoreplies, or email request systems (like fax back)
>
>
Or to automate subscription to a mailing list.
I'm not a *nix expert. But, this link
<http://forums.devshed.com/t64071/s.html> says forward file is better
than aliases file. Do you have any comment on it?
Then in that users /home/dir you create a '.forward' file, and stick in
email addresses, one per line. Sorta like a mini mailing list.
Draw backs to me, are for simple 1,2,3 email forwards this consumes a
userid, and requires a user in the /home
On my mail servers, there are only a hand full of /home/dir's and they are
for me, and whom ever is assisting me, the general users have no /home/dir
on any of my servers
Now the alias file, is as it is called, but for user accounts, you create
alias user names, and then point to real users (not email address),
although, it can forward to email addresses.
these are valid entries
owner: root
admins: root, john, jane, j...@otherplace.com
some-script: root, "|/etc/smrsh/script.php"
filter: "|/etc/smrsh/filter.php"
Then is the /etc/virtusertable file, this file maps email addresses to user
accounts. you can also forward email from here.
here are valid entries:
jo...@mydomain.com john
in...@mydomain.com john
nore...@mydomain.com filter
s...@domain.com s...@otherdomain.com
@domain.com error 550: Sorry, invalid user.
So IMHO, I use as follows:
/etc/alias to set up filter scripts.
/etc/virtusertable to map emails to user names
.forward for mini distribution lists
--
Mike Bradley
http://www.gzentools.com -- free online php tools
"R. Rajesh Jeba Anbiah" <ng4rrj...@rediffmail.com> wrote in message
news:abc4d8b8.04031...@posting.google.com...
procmail is your friend ;)
I agree with you here, and it could be simpler, one procmail entry and you
could be off and running, but I have seen to many people screw up *all* the
email on a system from a bad entry.
<some rational explanations snipped>
> So IMHO, I use as follows:
> /etc/alias to set up filter scripts.
> /etc/virtusertable to map emails to user names
> .forward for mini distribution lists
Indeed a very useful post.
--
"Democracy: Where all citizens are politicians and all politicians are citizens"
Email: rrjanbiah-at-Y!com