PHP Classes

File: mail_decoder_example.php

Recommend this page to a friend!
  Classes of Paul Scott  >  MIME Mail Decoder  >  mail_decoder_example.php  >  Download  
File: mail_decoder_example.php
Role: Example script
Content type: text/plain
Description: Example Script
Class: MIME Mail Decoder
Retrieve and decode messages from a POP3 account
Author: By
Last change: Added more documentation and better explanations to the example file, in order to make using this class as easy as possible.
Date: 10 years ago
Size: 1,416 bytes


Class file image Download
//first include the class

//fill out your username, password and mail server,
        //as well as giving the class a directory to work in.
        //This is where file attachments will be saved!
        //PS Make sure it is writeable!
$mail = new mail('', 'password', 'username', '/var/www/mymailapp/mail/');

//lets connect to the mailserver now.
        //NOTE: This setup will leave the messages on the server
        //If you would like to delete the messages once you have
        //downloaded them, set the $delete arg to true
        //Example: $messages = $mail->connectMail(TRUE);
$messages = $mail->connectMail();

// debug

//Now its time to decode the messages!
$decodedmail = $mail->decodeMessages($messages);

//insert the decoded mail to a db or a web page/whatever
    //The class will return an associative array of the messages,
        //as well as a reference to the file that it wrote from any
        //attachments. It gives the file a funky filename,
        //so that if you receive duplicate filenames, both files will
        //be preserved. Remember to rename your files before sending
        //them off again! This is done simply by replacing the bit after
        //the "_<timestamp>".