ptonev.com
July 21, 2017, 11:41:22 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: number of e-mails  (Read 9437 times)
andrew
Guest
« on: August 29, 2004, 05:32:17 am »

hi peter, i'm currently trying to find a script in php that will check all my pop3 accounts for the numbers of new e-mail, all i need is for someone like yourself to write me a script that will connect to a mailbox and display how many messages are on the server. I just need this done pretty basic so i can put the function into an array thing eg

function checkmailmymail(server,username,password,port,)

I really can't get my head arounf these pop3 protocols much they're really hard to twidle with in your php mail notify thingy.

Anyway, i would be truly grateful if you could do this for.

Regards,

Andrew Grant
Logged
ptonev
Administrator
Newbie
*****
Posts: 135


3119712
View Profile WWW
« Reply #1 on: August 29, 2004, 07:40:02 am »

Hi, Andrew.

If you have IMAP function you can use this code:

Code:
function checkEMail($host, $port, $user, $pass)
{
// open mailbox
$mbox = imap_open("{".$host.":".$port."/pop3/notls}INBOX", "$user", "$pass");

if($mbox === false)
{
return false;
}

// get emial count
$r = imap_num_msg($mbox);

// close mailbox
imap_close($mbox);

return $r;
}


but of you can't use IMAP you must how I make this on my other script.
Write me if you can't extract code from phpMailNotification.
Logged
andrew
Guest
« Reply #2 on: August 29, 2004, 09:55:53 am »

hello, your english is a little unclear, thanks anyway.

I have a little problem
i get the error msg: error: Call to undefined function: imap_open() in /home/ghs/public_html/mob02/index.php on line 6

. its a pop3 server and definetly not an imap one but i think that this server doen't like this code. my php config is probably too old. but i can't modify that now so i'll try it on another server i have but i really don't think it'll work.

Really don't understand the code in your phpMail Notification

cheers,

andrew
Logged
ptonev
Administrator
Newbie
*****
Posts: 135


3119712
View Profile WWW
« Reply #3 on: August 29, 2004, 12:00:21 pm »

> hello, your english is a little unclear, thanks anyway.

Yes, that is. English is not my mother language.

> ... Call to undefined function: imap_open() ...

This mean that you don't have installed IMAP functions on you hosting.

Try this code that use socket to connect to POP3.

Code:
function checkEMail($host, $port, $user, $pass)
{
$fp = fsockopen($host, $port, $errno, $errstr);

if(!$fp)
{
// could not open socket connection
$r = false;
}
else
{
$res = fgets($fp, 200);

if(substr($res, 0, 3) == "+OK")
{
fputs($fp, "USER $user\n");
fgets($fp, 200);

  fputs($fp, "PASS $pass\n");
$res = fgets($fp, 200);

if(substr($res, 0, 3) == "+OK")
{
  fputs($fp, "STAT\n");
$res = fgets($fp, 200);

if(substr($res, 0, 3) == "+OK")
{
$res = explode(" ", $res);
$r = $res[1];
}
else
{
$r = false;
}
}
else
{
$r = false;
}
}
else
{
$r = false;
}

fputs($fp, "QUIT\n");
fclose($fp);
}

return $r;
}
Logged
andrew
Guest
« Reply #4 on: August 29, 2004, 09:15:42 pm »

hey it all works now thanks a lot. you've made my day
Logged
ptonev
Administrator
Newbie
*****
Posts: 135


3119712
View Profile WWW
« Reply #5 on: August 30, 2004, 06:32:25 pm »

Hi, andrew.

I happy that can help you.
Logged
andrew
Guest
« Reply #6 on: August 31, 2004, 12:29:34 am »

the only thing is i can only check my mail server on the hosting server related eg.

i can only check mail.domain.com if the script is on www.domain.com which is a  pain in the arse, and it means the script has to be on all my servers and i have to have a central page on my pc that uses iframes to gather all the pages in one central location.

any comments?
Logged
ptonev
Administrator
Newbie
*****
Posts: 135


3119712
View Profile WWW
« Reply #7 on: August 31, 2004, 01:05:02 am »

Hi,

If I can understand you right, you say that you can't check POP3 email with different from mail.domain.com format.

But you can use IP instead domain name, and must can open all email servers that have POP3 and it is allowed to access.

If I don't understand you right, write me again and descript problem simply.

Best regards,
Logged
andrew
Guest
« Reply #8 on: September 03, 2004, 05:08:38 am »

well say my script checks e-mails @ mail.blahblah.com
and the actual script is on the www.myblah.com website then it won't work and it would only work for checking mail.myblah.com.

Something to do with the domain probably?


cheers, andrew
Logged
ptonev
Administrator
Newbie
*****
Posts: 135


3119712
View Profile WWW
« Reply #9 on: September 03, 2004, 11:01:17 pm »

Hi,

I thing that you have problem on mail.blahblah.com server.

I test script that:

1. script is on ptonev.xxx.xxxx.com
2. i check account that is on mail.yyy.com

and all work fine.

Try to connect with telnet into mail.blahblah.com server.

type this in command prompt:
Code:
telnet <-
open mail.blahblah.com 110 <-
USER <user_name> <-
PASS <password> <-
xxx
LIST <-
yyy
QUIT <-


 <- is enter key, xxx is information that mail server print, yyy is other information that mail server print

If this test don't pass that you have some problem with mail server and you must ask you ISP/HOSTING for that is possible to connect to POP3 on mail.blahblah.com server.

That is, best regards,
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!