T4VN is an online PHP Help community that provides PHP Tutorials, PHP Examples, PHP Scripts, PHP Support
    HOME  |  HOSTING COUPON  |  TEMPLATE  |  PHP SCRIPTS  |  LINK TO US  |  LINK  |  REGISTER | CONTACT
::: Member Login :::
 Username
 Password
 
Forgot your password ?
::: PHP Tutotal :::
  PHP Basic (7)
  PHP Advanced (4)
  PHP Database (2)
  Coding Step By Step (8)
  PHP and AJAX (0)
::: PHP Example :::
  Arrays (1)
  Code Highlighters (3)
  Database Functions (12)
  Date & Time (5)
  E-Mail (6)
  Forms (5)
  Guestbooks (1)
  Logging (2)
  Miscellaneous (10)
  Password Generators (3)
  Randomizers (3)
  String Manipulation (10)
  User Authentication (6)
::: Search On T4VN :::
::: T4VN Statistics :::
  PHP Scripts : 64
  PHP Example : 67
  PHP Tutorials : 21
  PHP News : 93
  Total Coupon : 36
  Other Tutorials :
  Member : 215
  Visitor Online : 2
  Today Visit: 292
  Total Visitor : 301314
  Most Online : 41
::: Sponsored Links :::

PR 4 For This Webpage

Vinaora Logo
Home Today :

Display Emails (PHP)

Author : toweter

With this PHP code snippet you can show an email overview and display emails. This example has been written for POP3 accounts. If you're using an IMAP account just replace /pop3 with /imap/notls

PHP Example :

<?php 
  
function show_mails($server$account$password
  { 
    
$mailbox imap_open("{".$server.":110/pop3}INBOX"$account$password); 
    
$mails imap_fetch_overview($mailbox,"1:*"FT_UID); // This is fetching an overview of all emails 

    // Output as a table: 
    
$return '<table width="100%"> 
                 <tr> 
                   <td><b>#</b></td> 
                   <td><b>From</b></td> 
                   <td><b>Date / Time</b></td> 
                   <td><b>Subject</b></td> 
                 </tr>'

    
$size count($mails); // Number of messages 
    
$cmsg 0// This is used to have a continously number 
    
for($i=$size-1;$i>=0;$i--) 
    { 
      
$cmsg++; 
      
$value $mails[$i]; 
      
$return .= '<tr><td>'.$cmsg.'</td><td>'.$value->from.'</td><td>'.$value->date.'</td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$value->msgno.'">'.$value->subject.'</a></td></tr>'
    } 
    
$return .= '</table>'
    
imap_close($mailbox); 
    return 
$return
  } 

  function 
show_mail($id$server$account$password
  { 
    
$mailbox imap_open("{".$server.":110/pop3}INBOX"$account$password); 
    
$mail imap_body($mailbox,$idFT_UID); 
    
// This is fetching the email.. 
    
$mail htmlentities(stripslashes($mail)); 
    
/* stripslashes is stripping the slashes, htmlentities transforms all of the non-regular symbols to their equal html code expression. */ 
    
$return '<pre>'.$mail.'</pre>'
    
imap_close($mailbox); 
    return 
$return
  } 

  if(isset(
$_GET['id'])) 
    if(
is_numeric($_GET['id'])) 
      echo 
show_mail($_GET['id'], "YourServerAddress""Account""Password"); 
    else 
      echo 
'wrong parameter'
  else 
    echo 
show_mails("YourServerAddress""Account""Password"); 
?>


Used functions:
Can be found at this web address (I'm technically not allowed to post links yet...): php.de/ftopic31562.html

Other Example
Mail with attachments
Sending HTML email


::: Resources :::
  Links Directory
  Programming 2 3
  Webmaster 2 3
  Web Design 2 3
  Web Hosting 2 3
  Other Links 2 3
  Asian ShowBiz News
  Teach Seo For You
::: New Templates :::




::: Other Tutorials :::
 Program Design

  Powered By T4VN.NET - Version 2.0 - CopyRight © T4VN.NET 2005-2007