Hvorfor virker $body ikke?
Hej..Jeg er ved at lave en mobog (som nogle nok allerede ved =D)
Men har et nyt problem (eller faktisk ikke nyt) Kan ikke få udskrevet $body, ved ikke hvorfor, men har næsten prøvet ALT.
Jeg bruger Richard Heyes Net_pop3.php og mimeDecode.php
(jeg kan godt udskrive $body via $pop3->getbody(1), men det er ulæselig)
OBS: dette er bare et test script
-------------------> Net_POP3_example.php <-----------------------
<html>
<body>
<?php
include('./POP3.php');
include('./mimeDecode.php');
$user='mob@domæne.com';
$pass='PASSWORD';
$host='pop.domæne.com';
$port="110";
// Create the class
$pop3 =& new Net_POP3();
//$pop3->setDebug();
// Connect to localhost on usual port
// If not given, defaults are localhost:110
if(PEAR::isError( $ret= $pop3->connect($host , $port ) )){
echo "ERROR: " . $ret->getMessage() . "\n";
exit();
}
// Login using username/password. APOP will
// be tried first if supported, then basic.
//$pop3->login($user , $pass , 'APOP');
//$pop3->login($user , $pass , 'CRAM-MD5');
if(PEAR::isError( $ret= $pop3->login($user , $pass,'USER' ) )){
echo "ERROR: " . $ret->getMessage() . "\n";
exit();
}
$params = array(
'input' => $message,
'crlf' => "\r\n",
'include_bodies' => TRUE,
'decode_headers' => TRUE,
'decode_bodies' => TRUE
);
$message=new Mail_mimeDecode($pop3->getMsg(1));
$mailObj=$message->decode($params);
// Get Message Body
$body=$mailObj->parts[0]->body;
// Who is it from
$from=$mailObj->headers['from'];
// Get Subject
$subj=$mailObj->headers['subject'];
// Get Date
$date=$mailObj->headers['date'];
//Get content type
$contenttype=$mailObj->parts[0]->headers['content-type'];
//Get includes type
$type=$mailObj->parts[1]->ctype_secondary;
//Get Includes
$tmp=$mailObj->parts[1]->d_parameters['filename'];
//Get to email address
$to=$mailObj->headers['to'];
//Get total mails
$tot = $pop3->numMsg();
//Get size on email
$size = $pop3->getSize();
echo "Subject: <b>".$subj."</b><br />";
echo "From: <b>".$from."</b><br />";
echo "To: <b>".$to."</b><br />";
echo "Include: <b>".$tmp."</b><br />";
echo "type: <b>".$type."</b><br />";
echo "Content type: <b>".$contenttype."</b><br />";
echo "Date: <b>".chgFormatDate($date)."</b><br />";
echo "Size: <b>".$size."</b> kb<br />";
echo "----------------------------<br />";
echo $body;
//$pop3->getBody(1)
//$pop3->deleteMsg(1);
// Disconnect
$pop3->disconnect();
//Date function
function chgFormatDate($date){
$timestamp = strtotime($date);
$date = date('d-m-Y H:i:s', $timestamp);
return $date;
}
?>