mail server secure

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
navid
Forum Commoner
Posts: 68
Joined: Tue Sep 24, 2002 3:14 am
Location: iran

mail server secure

Post by navid »

hi ,
I have a problem with a mail server.
This mail server has top secure.
I will connect to this mail server with a username and password to my account.
At first time I connect to mail server successfully.
If I connect to my account again, the mail server will not allow.
But after 3 or 4 seconds the mail server allows me to connect to my account.
I connect to the mail server with imap_open().
this mail server is pop.hotpop.com.
for example address email is "username@hotpop.com".
if you will test it you can create a free account in http://www.hotpop.com
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I don not know much about imap, but in the old ages of pop3 ( ;) ) it was quite common to let keep the file lock (or lock-file) even when the user logged out and check the create time at the next login attempt.
This way numerous logins in a short interval could be prevented.
Why do you want to login so often?
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Use POPS! The data gets sent encrypted not in text format, which means it's more safer. And introduce Firewall.
If I connect to my account again, the mail server will not allow.
Why do you need to connect twice.
navid
Forum Commoner
Posts: 68
Joined: Tue Sep 24, 2002 3:14 am
Location: iran

Re:Why do you ........?

Post by navid »

I use functions in my script.
E.g. I have a function to read only header.
Another function to read only number of emails.
And another function to read only body of email.
Etc.
They need to connect to mail server.
I use for each function an imap_open.
I know this work is wrong but …..
I try to use imap_open() function only for first time and to pass the result of imap_open() to another functions but it does fail.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you can store the connection-id in $GLOABLS, all functions can access this array.

http://www.php.net/manual/en/reserved.v ... es.globals
navid
Forum Commoner
Posts: 68
Joined: Tue Sep 24, 2002 3:14 am
Location: iran

test new way

Post by navid »

hi dear
in this script used global variable.
but i have problem yet.
there is source of progrom in the bottom of this page.
if you connect to mail box, this script show number of message in your mail box.
then if you do refresh your page for more time you will see a Warning.

i think my algorithm is fail. :!: :!: :!:
i need guide
bay


theWarning is:
Warning: Couldn't open stream {pop.hotpop.com:110/pop3} in /..../...../...????.php on line 5


the new script is :

<?php
require('functions.php');
if(!session_is_registered('loggedin'))
{
$pop=imap_open("{ your server:110/pop3}","user name ","your password");
}
//-----------------main part-------------------//
switch ($action)
{
###############################
// show a email //
###############################
case 'get_mail':
if(session_is_registered('loggedin'))
{$num=num();
if(isset($mail) and ($mail>0 and $mail<=$num))
{
/* get a message
.
.
.
.
*/
}
}
break;
###############################
// show all mail //
###############################
default:
$num=num();
switch ($num)
{
case -1:
/*--------//
.
.
.
show "you did fail"...........
.
.
.
//--------*/
break;
case 0:
session_register('loggedin');
$loggedin = 1;
$num_msg = 0;
/*--------//
.
.
.
show "you havent any emil in your inbox"...........
.
.
.
//--------*/
break;
default:
session_register('loggedin');
$loggedin = 1;
$num_msg=$num;
///-------------///
echo $num_msg;
///------------///
break;
}
break;
###############################
// end //
###############################
}
?>


and function source is:

<?php
function num()
{
if ($GLOBALS['pop'] == false)
return (-1);
else
{
if (($num_messages = @imap_num_msg($GLOBALS['pop'])) == 0)
{
return (0);
}
else
{
return($num_messages);
}
}
}

function inbox(........)
{
/*
.
.
.
*/
}

function get_mail(.......)
{
/*
.
.
.
*/
}


?>
navid
Forum Commoner
Posts: 68
Joined: Tue Sep 24, 2002 3:14 am
Location: iran

again

Post by navid »

hi all & volka & Takuma
i can not find a good way .
i test "$GLOBALS" and "session" for return result the "imap_open()".
but if imap_open() is successful this result is "1".
please help me :cry:
Post Reply