POP3

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
marce23
Forum Newbie
Posts: 11
Joined: Tue Apr 06, 2004 9:35 am

POP3

Post by marce23 »

Hi
Does anyone know, how i´m able to connect to a pop3-server and display my new mails in my own HTML-style???
thx
marce23
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post by liljester »

if you want to learn network programming with php it would be a fun project to create a mail application... if you just want a quick way to do it, you should prolly find a free php email script. i think ive seen squirrelmail mentioned on this forum before
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Code: Select all

<?
// connecting to a pop3 /imap

$mail = imap_open('{mail.server.com:143}', ' username' , 'password' ); //imap
$mail = imap_open(' {mail.server.com/pop3}', ' username' , 'password'); //pop3

$headers = imap_headers($mail); // get mail headers

$last = imap_num_msg($mail);
$header = imap_header($mail, $last);

$body = imap_body($mail, $last); // grap body

imap_clode($mail); // closing connection
?>
hope this will help
marce23
Forum Newbie
Posts: 11
Joined: Tue Apr 06, 2004 9:35 am

Post by marce23 »

I´ve a problem
If i type at ??? pop3.web.de

$mail = imap_open('{???}', '' , '' ); //imap
$mail = imap_open(' {???}', '' , ''); //pop3

I get these Error:

Fatal error: Call to undefined function: imap_open() in D:\Programme\Apache Group\Apache2\htdocs\mail\mail.php on line 4
marce23
Forum Newbie
Posts: 11
Joined: Tue Apr 06, 2004 9:35 am

Post by marce23 »

What have i to put into the ???-field
Mail Server:
imap.web.de
smtp.web.de
pop3.web.de

marce23
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

its not a problem with the ??? field. Look at the error maybe you're missing a module or something.
marce23
Forum Newbie
Posts: 11
Joined: Tue Apr 06, 2004 9:35 am

Post by marce23 »

<?php

$connection = fsockopen('pop3.server.de',110);
if($connection)
{
echo fgets($connection);
fputs($connection,'USER yourusername\r\n');
echo fgets($connection);
fputs($connection,'PASS yourpassword\r\n');
echo fgets($connection);
fputs(connection,'LIST\r\n');
echo fgets($connection);
fputs(connection,'QUIT\r\n');
echo fgets($connection);
fclose($connection);

}

?>

<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>!!!:
+OK WEB.DE POP3-Server
Fatal error: Maximum execution time of 30 seconds exceeded in D:\Programme\Apache Group\Apache2\htdocs\new.php on line 8
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

did you build youre php with

#--with-imap or --with-imap-ssl and if with a self-made certificate add this aswell..

/novalidate-cert ;-)


###
Than try the following again..

Code: Select all

<?
// connecting to a pop3 /imap

// imap connection....
$mail = imap_open('{mail.server.com:143}', ' username' , 'password' ); 

// for pop3 
$mail = imap_open(' {mail.server.com/pop3}', ' username' , 'password'); 

$headers = imap_headers($mail); // get mail headers

$last = imap_num_msg($mail);
$header = imap_header($mail, $last);

$body = imap_body($mail, $last); // grap body

imap_clode($mail); // closing connection
?>
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

The error means the imap_open is an undefined function, just in case someone was confused. So like they said, you need to install the ... somethin... to get it to be recognized.
Post Reply