Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server = "mail.site.com:995/pop3/ssl/novalidate-cert";
- $folder = "INBOX";
- $username = "dev+site.com";
- $password= "dev";
- if( !$conn = @imap_open( "{".$server."}$folder", $username, $password ) ) {
- foreach( imap_errors() as $error ) {
- echo "$error <br />";
- }
- } else {
- // fetch the messages
- $msgCount = imap_num_msg( $conn );
- if( $msgCount == 0 ) {
- echo "<h1>Mailbox is empty</h1>";
- } else {
- for( $i = 1; $i <= $msgCount; ++$i ) {
- echo "<b>Message $i of $msgCount</b><br />";
- $header = imap_header( $conn, $i );
- $from = $header->from[0]->mailbox; // just the name, no hostname
- $subject = $header->subject;
- $body = explode( "\n", imap_body( $conn, $i ) ); // first line of the body
- echo "From: $from <br />Subject: $subject <br />Message: {$body[0]}<br /><br />";
- }
- }
- imap_close( $conn );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement