PHP Imap Functions - anyone have experience RECEIVING email?
I'm looking to just learn basic stuff how to recieve email from a POP account, all I need to know for starters is how to get a list of the emails that are there, and be able to view them. I can't find any good tutorials, anyone know of any or can provide some help?
- Keith
AIM: Superwormy
Email: keithp@logosoftwear.com
PHP Imap Functions - anyone have experience RECEIVING email?
Moderator: General Moderators
-
superwormy
- Forum Commoner
- Posts: 67
- Joined: Fri Oct 04, 2002 9:25 am
- Location: CT
-
mistermickster
- Forum Newbie
- Posts: 3
- Joined: Wed Nov 20, 2002 9:01 am
- Location: Nottingham, England
I have been looking into this myself over the last couple of days and found this which I think is what you are looking for:
Call this script something like, listmail.php
Call this script view.php
Most of the functionality has been picked up from the manual at PHP.net
http://www.php.net/manual/en/ref.imap.php
Hope that helps
Call this script something like, listmail.php
Code: Select all
<html>
<head>
<title>List INBOX Messages</title>
</head>
<body>
<?php
$IP=gethostbyname("yourpop3.address.etc");
$mbox = imap_open("{" . "$IP:110/pop3" . "}INBOX", "username", "password");
echo "<p><h2>Mail in INBOX</h2><br>";
if (imap_num_msg($mbox) > 0) {
echo "<table><th>From</th><th>Subject</th><th>Date Received</th>";
for ($x=0; $x < imap_num_msg($mbox); $x++) {
$idx=$x+1;
$info=imap_headerinfo($mbox,$idx);
$subject=$info->subject;
$from=$info->fromaddress;
$date=$info->udate;
echo "<tr><td>$from</td><td><a href='view.php?num=$idx'>$subject</a></td><td>" . date('D j/M/Y h:i',$date) . "</td></tr>";
}
echo "</table>";
}
else {
echo "<h2><i>No Messages</i></h2>";
}
imap_close($mbox);
?>
</body>
</html>Code: Select all
<html>
<head>
<title>View GetMailBoxes</title>
</head>
<body>
<?php
$IP=gethostbyname("yourpop3.address.etc");
$mbox = imap_open ("{" . "$IP:110/pop3" . "}", "username", "password");
$info=imap_headerinfo($mbox,$num);
$subject=$info->subject;
$from=$info->fromaddress;
$date=$info->udate;
echo "<p><h3>From : $from<br>";
echo "Received : " . date("D j/M/Y H:i",$date) . " <br>";
echo "Subject : $subject<br></h3>";
$text=imap_fetchbody($mbox,$num,"1");
echo $text . "<br>";
imap_close($mbox);
?>
</body>
</html>http://www.php.net/manual/en/ref.imap.php
Hope that helps
-
superwormy
- Forum Commoner
- Posts: 67
- Joined: Fri Oct 04, 2002 9:25 am
- Location: CT
Warning: Couldn't open stream {64.72.132.17:110/pop3}INBOX in /imap_email/imap_email.php on line 5
Why do I get this...?
Why do I get this...?
Last edited by superwormy on Thu Nov 21, 2002 2:33 pm, edited 1 time in total.
-
superwormy
- Forum Commoner
- Posts: 67
- Joined: Fri Oct 04, 2002 9:25 am
- Location: CT
FIGURED IT OUT! THANKS!
As a note to anyone else who reads this, make sure you don't just use your ' username ' use your ENTIRE email address: name@email.com, NOT JUST name!
As a note to anyone else who reads this, make sure you don't just use your ' username ' use your ENTIRE email address: name@email.com, NOT JUST name!
-
mistermickster
- Forum Newbie
- Posts: 3
- Joined: Wed Nov 20, 2002 9:01 am
- Location: Nottingham, England