Probleme mit imap_funktionen

05/11/2009 - 15:57 von Julian Schlotterbeck | Report spam
Hier mein Code:

class MailServer {
protected $connection;

function __construct() {
$this->connect();
}

function connect() {
$host = '{217.114.75.67:143/notls}INBOX';
$connection = @imap_open($host, 'ich', 'geheim') or die(imap_errors
());

$this->getHeader();
$this->closeConnection();
}

function getHeader() {
echo "<p><h1>Mailboxes</h1>";
$folders = imap_listmailbox ($connection, $host, "*");

if ($folders == false) {
echo "Call failed<br>";
} else {
while (list ($key, $val) = each ($folders)) {
echo $val."<br>";
}
}

echo "<p><h1>Headers in INBOX</h1>";
$headers = imap_headers ($connection);

if ($headers == false) {
echo "Call failed<br>";
} else {
while (list ($key,$val) = each ($headers)) {
echo $val."<br>";
}
}

}

function closeConnection() {
imap_close($connection);
}
}




Und hier die Ausgabe:

Mailboxes

Warning: imap_listmailbox(): supplied argument is not a valid imap
resource in /var/www/newsletterAuslesen/MailServer.class.php on line
26
Call failed

Headers in INBOX

Warning: imap_headers(): supplied argument is not a valid imap
resource in /var/www/newsletterAuslesen/MailServer.class.php on line
37
Call failed

Warning: imap_close(): supplied argument is not a valid imap resource
in /var/www/newsletterAuslesen/MailServer.class.php on line 50
 

Lesen sie die antworten

#1 Werner Flamme
05/11/2009 - 16:05 | Warnen spam
Julian Schlotterbeck [05.11.2009 15:57]:
Hier mein Code:

class MailServer {
protected $connection;

function __construct() {
$this->connect();
}

function connect() {
$host = '{217.114.75.67:143/notls}INBOX';
$connection = @imap_open($host, 'ich', 'geheim') or die(imap_errors
());

$this->getHeader();
$this->closeConnection();
}

function getHeader() {
echo "<p><h1>Mailboxes</h1>";
$folders = imap_listmailbox ($connection, $host, "*");

if ($folders == false) {
echo "Call failed<br>";
} else {
while (list ($key, $val) = each ($folders)) {
echo $val."<br>";
}
}

echo "<p><h1>Headers in INBOX</h1>";
$headers = imap_headers ($connection);

if ($headers == false) {
echo "Call failed<br>";
} else {
while (list ($key,$val) = each ($headers)) {
echo $val."<br>";
}
}

}

function closeConnection() {
imap_close($connection);
}
}




Und hier die Ausgabe:

Mailboxes

Warning: imap_listmailbox(): supplied argument is not a valid imap
resource in /var/www/newsletterAuslesen/MailServer.class.php on line
26
Call failed

Headers in INBOX

Warning: imap_headers(): supplied argument is not a valid imap
resource in /var/www/newsletterAuslesen/MailServer.class.php on line
37
Call failed

Warning: imap_close(): supplied argument is not a valid imap resource
in /var/www/newsletterAuslesen/MailServer.class.php on line 50



Klar, $connection ist eine Variable, die lokal zur Methode ist. Du
solltest $this->connection benutzen.

HTH
Werner

Ähnliche fragen