Created
September 26, 2014 15:32
-
-
Save eresende/4423f9f2c3a3f416e454 to your computer and use it in GitHub Desktop.
Test IMAP connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mail_server = "mail.example.com" ; | |
$mail_username = "[email protected]" ; | |
$mail_password = "a very long and unbreakable password" ; | |
$mail_port = 143 ; | |
$mail_folder = 'INBOX'; | |
echo "<h1>".$mail_username." on ".$mail_server."</h1>\n\n" ; | |
$mbox = imap_open("{".$mail_server.":".$mail_port."/imap/novalidate-cert}".$mail_folder, $mail_username, $mail_password) or die("Error opening mailbox: ".imap_last_error()); | |
$mailboxheaders = imap_headers($mbox); | |
if ($mailboxheaders == false) { | |
echo "<p>".$mail_folder." is empty.</p>\n\n"; | |
} else { | |
echo "<h2>".$mail_folder."</h2>\n" ; | |
echo "<ol>\n" ; | |
$msgno = 0; | |
foreach ($mailboxheaders as $val) { | |
$msgno++; | |
echo " <li>".$val ."</li>\n"; | |
} | |
echo "</ol>\n\n" ; | |
} | |
imap_close($mbox); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment