Home > Archive > PHP Language > April 2005 > Get mail with PHP
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| there is a way to get the mails from a POP3 server using a PHP web based
application.Where i can found information about the libriries.
thanks
| |
| Library Curator 2005-04-17, 3:57 am |
| Here is a sample PHP script that will show the number of messages you
have on your mail server.
> <?
>
########################################
###############################
> # checkmail.php | last update Apr-10-2005 | Cyberdine Systems
#
> #
#
> # INFO
#
> # Checkmail displays the number of messages in a POP3
#
> # mailbox without downloading or viewing any of the messages.
#
> #
#
> # USAGE
#
> # Requires PHP4. Set the $host, $user, and $pass variables below and
#
> # execute the script.
#
> #
#
> # LICENSE
#
> # This script is absolutely free. Use at will. The author is not
#
> # responsible for lost email, blown up servers, or anything else
that #
> # results from the use of this script.
#
>
########################################
###############################
>
> $host = "mailserver";
> $user = "username";
> $pass = "password";
>
>
########################################
###############################
> # End Configuration
#
>
########################################
###############################
> #Until I rewrite my scripts, this will suffice for
bg-compatibility;
> if(phpversion() >= "4.2.0"){
> extract($_POST);
> extract($_SERVER);
> extract($_ENV);
> }
>
> #Format output for console or for web?
> $nl = ((isset($REMOTE_ADDR)) ? "<br>" : "\n");
>
> if(!$sock=fsockopen($host, 110, $err, $errno, 10))
> die("Couldn't connect to the POP server$nl");
>
> fputs($sock, "USER $user\r\n");
> $buf = fgets($sock, 1024);
> if($buf[0] != '+')
> die("POP server didn't like USER $user$nl");
> sleep(3);
> fputs($sock, "PASS $pass\r\n");
> $buf = fgets($sock, 1024);
> if($buf[0] != '+')
> die("POP server didn't like PASS$nl");
> sleep(3);
>
> fputs($sock, "STAT\r\n");
>
> $buf = fgets($sock, 1024);
> fputs($sock, "STAT\r\n");
> $buf2 = fgets($sock, 1024);
> list($stat, $num, $size) = split(' ', $buf2, 3);
> echo "There are $num message(s)$nl";
> fputs($sock, "QUIT\r\n");
> $buf = fgets($sock, 1024);
> fclose($sock);
>
> ?>
>
| |
| Library Curator 2005-04-23, 3:56 am |
| Here is a sample PHP script that will show the number of messages you
have on your mail server.
> <?
>
########################################
###############################
> # checkmail.php | last update Apr-10-2005 | Cyberdine Systems
#
> #
#
> # INFO
#
> # Checkmail displays the number of messages in a POP3
#
> # mailbox without downloading or viewing any of the messages.
#
> #
#
> # USAGE
#
> # Requires PHP4. Set the $host, $user, and $pass variables below and
#
> # execute the script.
#
> #
#
> # LICENSE
#
> # This script is absolutely free. Use at will. The author is not
#
> # responsible for lost email, blown up servers, or anything else
that #
> # results from the use of this script.
#
>
########################################
###############################
>
> $host = "mailserver";
> $user = "username";
> $pass = "password";
>
>
########################################
###############################
> # End Configuration
#
>
########################################
###############################
> #Until I rewrite my scripts, this will suffice for
bg-compatibility;
> if(phpversion() >= "4.2.0"){
> extract($_POST);
> extract($_SERVER);
> extract($_ENV);
> }
>
> #Format output for console or for web?
> $nl = ((isset($REMOTE_ADDR)) ? "<br>" : "\n");
>
> if(!$sock=fsockopen($host, 110, $err, $errno, 10))
> die("Couldn't connect to the POP server$nl");
>
> fputs($sock, "USER $user\r\n");
> $buf = fgets($sock, 1024);
> if($buf[0] != '+')
> die("POP server didn't like USER $user$nl");
> sleep(3);
> fputs($sock, "PASS $pass\r\n");
> $buf = fgets($sock, 1024);
> if($buf[0] != '+')
> die("POP server didn't like PASS$nl");
> sleep(3);
>
> fputs($sock, "STAT\r\n");
>
> $buf = fgets($sock, 1024);
> fputs($sock, "STAT\r\n");
> $buf2 = fgets($sock, 1024);
> list($stat, $num, $size) = split(' ', $buf2, 3);
> echo "There are $num message(s)$nl";
> fputs($sock, "QUIT\r\n");
> $buf = fgets($sock, 1024);
> fclose($sock);
>
> ?>
>
|
|
|
|
|