note 129402 added to function.imap-open
| From: | Anonymous | Date: | Tue, 16 Apr 2024 03:55:24 +0000 |
| Subject: | note 129402 added to function.imap-open | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221286@lists.php.net to get a copy of this message | ||
Updating ==> Function to test most of the possible options of a connection:
<?php
@ini_set('zlib.output_compression',0);
@ini_set('implicit_flush',1);
@ob_end_clean();
set_time_limit(0);
ob_implicit_flush(1);
function imapConfig($options, $i=0, $till = array()) {
if(sizeof($options)==$i)
return $till;
if(sizeof($till)==0)
$till[] = '';
$opt = $options[$i];
$new = array();
foreach($till as $t) {
foreach($opt as $o) {
if(strlen($o)==0)
$new[] = $t;
else
$new[] = $t.'/'.$o;
}
}
return imapConfig($options, $i+1, $new);
}
function imap_test($server, $dir, $username, $passw, $options) {
$configOptions = imapConfig($options);
echo '<table
style="border:none"><tr><th>Status</th><th>Option</th><th>Info</th></tr>';
foreach($configOptions as $c) {
ob_end_flush();
$mbox = @imap_open("{".$server.$c."}".$dir, $username, $passw);
$r='';
if (false !== $mbox) {
$check = imap_check($mbox);
$r = ['<span style="color: green">SUCCESS</span>',
"<b>$c</b>", $check->Mailbox];
$results['SUCCESS'][] = $r;
imap_close($mbox);
}
else {
$r = ['<span style="color: red">FAILED</span>',
"<b>$c</b>", imap_last_error()];
$results['FAILED'][] = $r;
}
echo
"<tr><td>${r[0]}</td><td>${r[1]}</td><td>${r[2]}</td></tr>";
ob_start();
$mbox=null;
}
echo '<tr><td colspan="2"><span style="color:
green"><br><br><br><< SUCCESS
>></span></td></tr>';
foreach($results['SUCCESS'] as $r){
echo
"<tr><td>${r[0]}</td><td>${r[1]}</td><td>${r[2]}</td></tr>";
}
}
echo "<PRE>";
$results=[];
$options=[];
//$options[] = array('debug');
$options[] = array('imap', 'imap2', 'imap2bis', 'imap4',
'imap4rev1', 'pop3'); //nntp
$options[] = array('', 'norsh');
$options[] = array('', 'ssl');
$options[] = array('', 'validate-cert', 'novalidate-cert');
$options[] = array('', 'tls', 'notls');
//print_r(imapConfig($options));
//It uses default service port by protocol
imap_test('SERVER', 'INBOX', 'USER', 'PASS');
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.131 (proxied: 2804:14c:124:88d6::1000)
----
Manual Page -- https://php.net/manual/en/function.imap-open.php
Edit -- https://main.php.net/note/edit/129402
Del: integrated -- https://main.php.net/note/delete/129402/integrated
Del: useless -- https://main.php.net/note/delete/129402/useless
Del: bad code -- https://main.php.net/note/delete/129402/bad+code
Del: spam -- https://main.php.net/note/delete/129402/spam
Del: non-english -- https://main.php.net/note/delete/129402/non-english
Del: in docs -- https://main.php.net/note/delete/129402/in+docs
Del: other reasons-- https://main.php.net/note/delete/129402
Reject -- https://main.php.net/note/reject/129402
Search -- https://main.php.net/manage/user-notes.php