$context is an object of class ezcMailPartWalkContext, which must contain
a valid callback function name to be applied to all mail parts. You can use
the collectPart() method, or create your own callback function which can
for example save the mail parts to disk or to a database.
For the properties you can set to the walk context see: {@link ezcMailPartWalkContext}
Example:
class App
{
public static function saveMailPart( $context, $mailPart )
{
code to save the $mailPart object to disk
}
}
use the saveMailPart() function as a callback in walkParts()
where $mail is an ezcMail object.
$context = new ezcMailPartWalkContext( array( 'App', 'saveMailPart' ) );
$context->includeDigests = true; // if you want to go through the digests in the mail
$mail->walkParts( $context, $mail );
public walkParts ( ezcMailPartWalkContext $context, ezcMailPart $mail ) | ||
$context | ezcMailPartWalkContext | |
ezcMailPart |
public function createEntry(ezcMail $mail) { $this->entry = new qaBlogEntry(); $this->entry->setSubject($mail->subject); $walkContext = new ezcMailPartWalkContext(array($this, 'walkPart')); $walkContext->filter = array('ezcMailText', 'ezcMailFile'); $mail->walkParts($walkContext, $mail); return $this->entry; }
/** * Processes file attachments. * * @param ezcMail $mail */ protected function processFiles(ezcMail $mail) { $context = new ezcMailPartWalkContext(array($this, 'addFile')); $context->filter = array('ezcMailFile'); $mail->walkParts($context, $mail); }