view email distribution list members with php

I need to get the list of email addresses that are part of a distribution list on an exchange server. I can connect fine, but the information returned is lacking the subscribers.

$hostname = '{rcdn-mail-1.abc123.com:993/imap/ssl}Inbox';
$username = 'user1';
$password = 'password1';

$mbox = imap_open($hostname,$username,$password) or die('Cannot connect: ' . imap_last_error());


$list = imap_lsub($mbox, "{cmo-maillist}", "*");
if (is_array($list)) {
foreach ($list as $val) {
    print_r($val) . "\n";
}
} else {
echo "imap_list failed: " . imap_last_error() . "\n";
}

imap_close($mbox); 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s