Example #1
1
 public function __construct(IMAP $imap, $mail, $attachmentsDirectory = null)
 {
     $this->imap = $imap;
     $this->connection = $imap->getConnection();
     $this->mail = $mail;
     $this->attachmentsDirectory = $attachmentsDirectory;
     $this->structure = imap_fetchstructure($this->connection, $this->mail->id, FT_UID);
 }
Example #2
0
 public function pub_notifier($o)
 {
     $account = $GLOBALS['conf']['imapMailBox']['accounts'][$o['account']];
     $imap = new IMAP($account['user'], $account['pass'], 'localhost', "143");
     $imap->noop();
     $response = $imap->listMailboxes();
     db($response);
     $response = $imap->select('INBOX', true);
     db($response);
     $response = $imap->subscribe('INBOX');
     db($response);
     $response = $imap->_responce(false);
     db($response);
     db('------');
     $r = $imap->idle();
     $response = $imap->_responce(false);
     db($response);
     $response = $imap->_responce(false);
     db($response);
     $response = $imap->_responce(false);
     db($response);
 }
Example #3
0
 public function __construct(IMAPMailbox $mailbox, $sequence)
 {
     $result = imap_fetch_overview($mailbox->getStream(), $sequence);
     if (FALSE === $result) {
         throw new Exception('Overview failed: ' . imap_last_error());
     }
     $this->mailbox = $mailbox;
     foreach ($result as $overview) {
         if (!isset($overview->subject)) {
             $overview->subject = '';
         } else {
             $overview->subject = IMAP::decodeToUTF8($overview->subject);
         }
     }
     parent::__construct($result);
 }
Example #4
0
function imap_show_attach()
{
    $imap = new IMAP();
    if ($imap->open('david.touzeau', '180872', '127.0.0.1', '143')) {
        $hash = $imap->_decode_msg($_GET["msgid"]);
        $filename = $_GET["ShowMessageAttachment"];
        header("Content-type: " . $hash["attachment"][$filename]["type"]);
        header("Content-Disposition: attachment; filename=" . $filename);
        echo $hash["attachment"][$filename]["filedata"];
    }
}
 $formmail = new FormMail($db);
 $attachedfiles = $formmail->get_attached_files();
 $filepath = $attachedfiles['paths'];
 $filename = $attachedfiles['names'];
 $mimetype = $attachedfiles['mimes'];
 $trackid = GETPOST('trackid', 'aZ09');
 // Feature to push mail sent into Sent folder
 if (!empty($conf->dolimail->enabled)) {
     $mailfromid = explode("#", $_POST['frommail'], 3);
     // $_POST['frommail'] = 'aaa#Sent# <*****@*****.**>'	// TODO Use a better way to define Sent dir.
     if (count($mailfromid) == 0) {
         $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>';
     } else {
         $mbid = $mailfromid[1];
         /*IMAP Postbox*/
         $mailboxconfig = new IMAP($db);
         $mailboxconfig->fetch($mbid);
         if ($mailboxconfig->mailbox_imap_host) {
             $ref = $mailboxconfig->get_ref();
         }
         $mailboxconfig->folder_id = $mailboxconfig->mailbox_imap_outbox;
         $mailboxconfig->userfolder_fetch();
         if ($mailboxconfig->mailbox_save_sent_mails == 1) {
             $folder = str_replace($ref, '', $mailboxconfig->folder_cache_key);
             if (!$folder) {
                 $folder = "Sent";
             }
             // Default Sent folder
             $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url() . $folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
             if (FALSE === $mailboxconfig->mbox) {
                 $info = FALSE;
Example #6
0
<?php

require dirname(__FILE__) . '/IMAP/include.php';
try {
    // connect to IMAP server
    $imap = new IMAP('mail.domain.com', '*****@*****.**', 'password');
    $imap->connect();
    // get list of all mailboxes
    $mailboxArray = $imap->getMailboxArray();
    print_r($mailboxArray);
    // prints:
    //    inbox
    //    sent
    //    trash
    //    junk
    //    ...
    // get all messages in INBOX (print array of UID)
    $uidArray = $imap->getMessageArray('inbox');
    print_r($uidArray);
    // prints:
    //    1750
    //    1751
    //    1752
    //    1753
    //    1754
    //    1755
    //    ...
    // get message headers by UID=1751. Prints formatted message array.
    $headerArray = $imap->getMessage('inbox', 1751, true);
    print_r($headerArray);
    // prints:
 *
 */
error_reporting(E_ALL | E_STRICT);
// IMAP support on PHP is not a standard feature...
if (!function_exists('imap_open')) {
    echo "\nFATAL_ERROR: imap_open not found!\n\n";
    echo "Please ensure that your installation of PHP has IMAP support\n\n";
    echo "This can be done in several ways, apt-get, yum, brew, etc.\n\n";
    echo "Please see your network administrator, O.S. Dcumentation,\n a Qualified Professional for details. :)\n\n";
    exit(-1);
}
_args($argc, $argv);
echo "\nS: ";
$S = new IMAP($_ENV['src']);
echo "\nT: ";
$T = new IMAP($_ENV['tgt']);
$src_path_list = $S->listPath();
foreach ($src_path_list as $path) {
    echo "S: {$path['name']} = {$path['attribute']}\n";
    // Skip Logic Below
    if (_path_skip($path)) {
        echo "S: Skip\n";
        continue;
    }
    // Source Path
    $S->setPath($path['name']);
    $src_path_stat = $S->pathStat();
    // print_r($src_path_stat);
    if (empty($src_path_stat['mail_count'])) {
        echo "S: Skip {$src_path_stat['mail_count']} messages\n";
        continue;
Example #8
0
	/**
	 * Recupera o conteúdo da mensagem
	 */
	public function fetch() {
		$this->imap->fetch( $this );
	}
Example #9
0
 private function getAttribute($params, $name)
 {
     foreach ($params as $object) {
         if ($object->attribute == $name) {
             return IMAP::decodeToUTF8($object->value);
         }
     }
     return NULL;
 }
Example #10
0
    Imports Messages from POP3/IMAP Mailbox to Request Queue
    Imports and Adds Attachments too
*/
/**
  Uses the Native PHP to read a IMAP/POP3(+SSL) mailbox and put messages into Imperium
  @todo drop dependency on ZF, use base-PHP
  @todo import to Trac using the Trac Web Interface - basically HTTP POST
*/
// CLI
require_once dirname(dirname(__FILE__)) . '/lib/cli.php';
if (empty($_ENV['mail']['imap'])) {
    die("No IMAP Configuration\n");
}
echo "Checking: {$_ENV['mail']['imap']}\n";
$imap = new IMAP($_ENV['mail']['imap']);
$imap_stat = $imap->pathStat();
if (empty($imap_stat)) {
    die("Cannot Check Mailbox\n");
}
// print_r($imap_stat);
if ($imap_stat['mail_count'] == 0) {
    return 0;
}
for ($i = $imap_stat['mail_count']; $i >= 1; $i--) {
    $stat = $imap->mailStat($i);
    // echo "S: {$stat['subject']} {$stat['MailDate']}\n";
    // print_r($stat['from'][0]);
    $from = $stat['from'][0];
    $from_mail = $from->mailbox . '@' . $from->host;
    if (!preg_match('/[\\w\\+\\.]+@[\\w\\.]+/', $from_mail)) {