How to upload file to amazon using filemanager (Responsive Filemanager) in tinymce - tinymce

How can i upload my file to amazon in filemanager (responsive filemanager) and encrypt it once the image is uploaded.
when using this setup it only save all image on my local folder, any thoughts in this matter?
and when i change my 'curent_path' to 'https://s3-us-west-2.amazonaws.com/dir/subdir/directoryhere it give me error on php
below is my sample code setup,
if (!empty($_SERVER["SERVER_NAME"])) {
$host = $_SERVER["SERVER_NAME"];
} else {
$host = "localhost";
}
$urlParts = explode(".",$host);
$subdomain = $urlParts[1];
if ($subdomain == "tvms") {
$link = "https://s3.amazonaws.com";
$bucket = "tvms-live";
} else {
$link = "https://s3-us-west-2.amazonaws.com";
$bucket = "tvms-uat";
}
define('USE_ACCESS_KEYS', false); // TRUE or FALSE
define('DEBUG_ERROR_MESSAGE', true); // TRUE or FALSE
$config = array(
//'base_url' => ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"). "://". #$_SERVER['HTTP_HOST'],
'base_url' => $link,
'upload_dir' => '/' . $bucket . '/acvr/uploads/hostedimages/',
'current_path' => '../source/',
'thumbs_base_path' => '../thumbs/',
'mime_extension_rename' => true,
'ftp_host' => false, //put the FTP host
'ftp_user' => "user",
'ftp_pass' => "pass",
'ftp_base_folder' => "base_folder",
'ftp_base_url' => "http://site to ftp root",
// Directory where place files before to send to FTP with final /
'ftp_temp_folder' => "../temp/",
'ftp_thumbs_dir' => '/thumbs/',
'ftp_ssl' => false,
'ftp_port' => 21,
/* EXAMPLE
'ftp_host' => "host.com",
'ftp_user' => "test#host.com",
'ftp_pass' => "pass.1",
'ftp_base_folder' => "",
'ftp_base_url' => "http://host.com/testFTP",
*/
'multiple_selection' => true,
'multiple_selection_action_button' => true,
'access_keys' => array(
'key' =>'AAKJSKDFIOUEJKNRWELNQWEWQE',
'secret' => 'opisdfj2j3kl2n43249sdfijadsf890324'
),
heres the error message

Related

error sending email in codeigniter 3 and php 7

$config = [
'protocol' => 'sendmail',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_user' => '***************',
'smtp_pass' => '********',
'smtp_port' => 465,
'smtp_timeout' => '30',
'mailtype' => 'html',
// 'ssl' => [
// 'verify_peer' => false,
// 'veriry_peer_name' => false,
// 'allow_self_sign' => true
// ],// ini hanya jika jaringa tidak ssl/https, jangan dilakukan di produksi
'starttls' => true,
'charset' => 'utf-8',
'newline' => "\r\n"
];
Hi All, I have
I have tried to send mail from my local host but it return error like bellow,
Message: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream
Thank you for your help,
for sending mail from local i'm using SMTP. Please change your code with following code. It's working for me. Do not edit system file. That will create problem for you in future.
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = '********'; //your email id
$config['smtp_pass'] = '********'; //email id password
$config['smtp_port'] = 465;
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;

Fedex SOAP Request Failing

I am looking for the reason why the below request is failing to retrieve information. This is copied from the Fedex developer website and it doesn't work. When my program hits the GetRates line it throws a could not connect to host exception. I tried adding the connection_timeout and setting the default_timeout in php and neither appear to work. I contacted the Fedex dev team and they are receiving my post successfully I am just not able to get any response besides the fault. Has anyone had experience with Fedex or know what might cause this to be failing?
I am posting my current code below. I am using PHP7 on an AS400 machine using Zendserver.
<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0
require_once('../library/fedex-common.php5');
$newline = "<br />";
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../wsdl/RateService_v24.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('soap.wsdl_cache_ttl',0);
$client = new SoapClient($path_to_wsdl, array('trace' => 1, 'connection_timeout' => 30)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '24',
'Intermediate' => '0',
'Minor' => '0'
);
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['TotalInsuredValue']=array(
'Ammount'=>100,
'Currency'=>'USD'
);
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
try {
if(setEndpoint('changeEndpoint')){
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client -> getRates($request);
if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR'){
$rateReply = $response -> RateReplyDetails;
echo '<table border="1">';
echo '<tr><td>Service Type</td><td>Amount</td><td>Delivery Date</td></tr><tr>';
$serviceType = '<td>'.$rateReply -> ServiceType . '</td>';
if($rateReply->RatedShipmentDetails && is_array($rateReply->RatedShipmentDetails)){
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount,2,".",",") . '</td>';
}elseif($rateReply->RatedShipmentDetails && ! is_array($rateReply->RatedShipmentDetails)){
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Amount,2,".",",") . '</td>';
}
if(array_key_exists('DeliveryTimestamp',$rateReply)){
$deliveryDate= '<td>' . $rateReply->DeliveryTimestamp . '</td>';
}else if(array_key_exists('TransitTime',$rateReply)){
$deliveryDate= '<td>' . $rateReply->TransitTime . '</td>';
}else {
$deliveryDate='<td> </td>';
}
echo $serviceType . $amount. $deliveryDate;
echo '</tr>';
echo '</table>';
printSuccess($client, $response);
}else{
printError($client, $response);
}
writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}
function addShipper(){
$shipper = array(
'Contact' => array(
'PersonName' => 'Sender Name',
'CompanyName' => 'Sender Company Name',
'PhoneNumber' => '9012638716'
),
'Address' => array(
'StreetLines' => array('Address Line 1'),
'City' => 'Collierville',
'StateOrProvinceCode' => 'TN',
'PostalCode' => '38017',
'CountryCode' => 'US'
)
);
return $shipper;
}
function addRecipient(){
$recipient = array(
'Contact' => array(
'PersonName' => 'Recipient Name',
'CompanyName' => 'Company Name',
'PhoneNumber' => '9012637906'
),
'Address' => array(
'StreetLines' => array('Address Line 1'),
'City' => 'Richmond',
'StateOrProvinceCode' => 'BC',
'PostalCode' => 'V7C4V4',
'CountryCode' => 'CA',
'Residential' => false
)
);
return $recipient;
}
function addShippingChargesPayment(){
$shippingChargesPayment = array(
'PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
'Payor' => array(
'ResponsibleParty' => array(
'AccountNumber' => getProperty('billaccount'),
'CountryCode' => 'US'
)
)
);
return $shippingChargesPayment;
}
function addLabelSpecification(){
$labelSpecification = array(
'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
'ImageType' => 'PDF', // valid values DPL, EPL2, PDF, ZPLII and PNG
'LabelStockType' => 'PAPER_7X4.75'
);
return $labelSpecification;
}
function addSpecialServices(){
$specialServices = array(
'SpecialServiceTypes' => array('COD'),
'CodDetail' => array(
'CodCollectionAmount' => array(
'Currency' => 'USD',
'Amount' => 150
),
'CollectionType' => 'ANY' // ANY, GUARANTEED_FUNDS
)
);
return $specialServices;
}
function addPackageLineItem1(){
$packageLineItem = array(
'SequenceNumber'=>1,
'GroupPackageCount'=>1,
'Weight' => array(
'Value' => 50.0,
'Units' => 'LB'
),
'Dimensions' => array(
'Length' => 108,
'Width' => 5,
'Height' => 5,
'Units' => 'IN'
)
);
return $packageLineItem;
}
?>

How to send email with phpmailer in phalcon php

Im new in phalcon want a working example of phpmailer that send email from my site. currently i just figure out like this. i just follow this link: github.com/asyamedya/phalcon-phpmailer.
[config.php]
$config = new Phalcon\Config(array(
"app" => array(
"controllersDir"=> "app/controllers/",
"modelsDir" => "app/models/",
"viewsDir" => "app/views/",
"pluginsDir" => "app/plugins/",
"libraryDir" => "app/library/",
"helpersDir" => "app/helpers/",
"formsDir" => "app/forms/",
"cacheDir" => "cache/volt/",
"logsDir" => "cache/logs/",
"encryptKey" => "",
"baseUri" => "/demo/",
"StaticBaseUri" => "http://localhost/demo/",
"debug" => '0',
),
"mail" => array(
"driver" => "smtp",
"host" => "smtp.gmail.co",
"username" => "2munax#gmail.com",
"password" => "*****",
"security" => "tls", //ssl:465, tls:587
"port" => 587,
"charset" => "UTF-8",
"email" => "2munax#gmail.com",
"name" => "webmaster",
),
));
[loader.php]
use Phalcon\Loader;
$loader = new Loader();
$loader->registerDirs(
array(
APP_PATH . $config->app->controllersDir,
APP_PATH . $config->app->modelsDir,
APP_PATH . $config->app->pluginsDir,
APP_PATH . $config->app->libraryDir,
APP_PATH . $config->app->helpersDir,
APP_PATH . $config->app->formsDir,
APP_PATH . $config->app->cacheDir,
)
)->register();
[service.php]
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\Mvc\Router;
use Phalcon\Security;
use \PHPMailer as PHPMailer;
use Phalcon\Mvc\View\Engine\Volt;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Flash\Session as FlashSession;
use Phalcon\Logger\Adapter\File as Logger;
use Phalcon\Mvc\Model\Metadata\Apc as ApcMetaData;
use Phalcon\Session\Adapter\Files as SessionAdapter;
require(APP_PATH . $config->app->libraryDir . 'PHPMailer/PHPMailerAutoload.php');
$di->set('pmailer', function() use ($config){
$pmailer = new PHPMailer();
//$mail->setLanguage('fr', '/optional/path/to/language/directory/');
$pmailer->isSMTP(true);
$pmailer->SMTPDebug = 2; // Enable verbose debug output
$pmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$pmailer->Charset = $config->mail->charset;
$pmailer->Host = $config->mail->host;
$pmailer->SMTPAuth = true;
$pmailer->Username = $config->mail->username;
$pmailer->Password = $config->mail->password;
$pmailer->SMTPSecure = $config->mail->security;
$pmailer->Port = $config->mail->port;
$pmailer->addAddress($config->mail->email,$config->mail->name);
$pmailer->isHTML(true);
return $pmailer;
});
[controller index]
public function SendmailAction()
{
$this->pmailer->From = "2munax#gmail.com";
$this->pmailer->FromName = "user";
$this->pmailer->addReplyTo("2munax#gmail.com", "user");
$this->pmailer->addAddress('babymachinery83#gmail.com');
$this->pmailer->Subject = "email test !";
$this->pmailer->Body = "success!";
$this->pmailer->WordWrap = 70;
if(!$this->pmailer->send()){echo 'Message could not be sent.';
echo 'Mailer Error: ' . $this->pmailer->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
In my library i have this files.
[Library/PHPMailer/]
class.phpmailer.php
class.pop3.php
class.smtp.php
PHPMailerAutoload.php
class.phpmaileroauthgoogle.php
I'm not sure, but you I think this is wrong in your service.php
use Phalcon\PHPMailer;
Change it to
use \PHPMailer as PHPMailer;

trying to parse text and html from email over IMAP using MAIL::IMAPClient but text is hidden in parts and multi-parts

I can connect to the IMAP mail server easy enough:
use Mail::IMAPClient;
use MIME::Base64;
use MIME::Parser;
my $imap = Mail::IMAPClient->new(
Server => '192.168.2.2',
User => 'xxxxxx',
Password => 'yyyyyy',
Ssl => 1,
Uid => 1,
);
my $folders = $imap->folders
or die "List folders error: ", $imap->LastError, "\n";
print "Folders: #$folders\n";
$sfolder="INBOX.2012";
$imap->select( $sfolder )
or die "Select '$Opt{sfolder}' error: ", $imap->LastError, "\n";
my #msgs = $imap->messages or die "Could not messages: $#\n";
However, the text and html I want is not easily parsed due to codes like this:
Content-Transfer-Encoding:base64
Content-Type:text/html; charset=utf-8
Content-Transfer-Encoding:base64
Content-Type:text/html; charset=utf-8
Content-Transfer-Encoding:
Content-Type:multipart/mixed; boundary="----------=_4F0F4830.7079357A"
Multipart
Content-Transfer-Encoding:
Content-Type:multipart/mixed; boundary="----=_Part_4487195_1184536749.1326753403034"
Multipart
Content-Transfer-Encoding:
Content-Type:multipart/alternative; boundary=--boundary_164442_d184e417-739f-
46d6-824a-6ea1846e79de
Multipart
Content-Transfer-Encoding:
Content-Type:multipart/mixed; boundary="----=_Part_3882878_23916831.1326509484032"
Multipart
Content-Transfer-Encoding:
I tried this but it only works on a tiny number of different encodings.
if ($imap->get_header($msg,"Content-Transfer-Encoding")=~ /base64/i) {
print "\nMatch base64";
if ($imap->get_header($msg,"Content-Type")=~m/text/i ) {
push(#mail,decode_base64($imap->body_string($msg)));
}
elsif ($imap->get_header($msg,"Content-Type")=~m/image/i )
{ print "\nImage detected"; }
elsif ($imap->get_header($msg,"Content-Type")=~m/application/i )
{ print "\nApplication detected"; }
There are 7bit and 8bit variants and other encoding methods that contain the html or text I want for later use. I successfully use decode_base64() to decode base64. The worse ones to decode are the ones that contain multi-part codes. I feel like I am re-inventing the wheel and there must be a library or module that can do all the heavy lifting for me.
Other content types such as .jpg,.gif, and .pdf should simply be ignored. The multi-part emails contain at least 1 part that I an interested but many that are useless to me.
After further research this structure has some of the information I need but don't know how to get it out efficiently is another matter.
Dumping:$VAR1 = bless( {
'bodyparms' => {
'boundary' => '----=_NextPart_002_BC64_7D688C1F.A2FF9BE0'
},
'bodyextra' => undef,
'_top' => 1,
'bodydisp' => 'NIL',
'_id' => 'HEAD',
'bodysubtype' => 'mixed',
'PartsIndex' => {
'1.3' => bless( {
'bodyparms' => 'NIL',
'bodyid' => '<d9e26cc0-019c-4ac0-9b1e-9c9ac8424f52>',
'bodyextra' => 'NIL',
'bodydisp' => 'NIL',
'_id' => '1.3',
'bodysubtype' => 'jpeg',
'_prefix' => '1.3',
'bodysize' => '4808',
'bodytype' => 'image',
'bodyMD5' => 'NIL',
'bodylang' => 'NIL',
'bodydesc' => 'NIL',
'bodyenc' => 'base64'
}, 'Mail::IMAPClient::BodyStructure' ),
'1.1' => bless( {
'bodyparms' => {
'boundary' => '----=_NextPart_000_36AE_880DDD08.0A776E35'
},
'bodyextra' => undef,
'bodydisp' => 'NIL',
'_id' => '1.1',
'bodysubtype' => 'alternative',
'_prefix' => '1.1',
'bodytype' => 'MULTIPART',
'bodystructure' => [
bless( {
'bodyparms' => {
'charset' => 'utf-8'
},
'bodyextra' => 'NIL',
'bodyid' => 'NIL',
'bodydisp' => 'NIL',
'_id' => '1.1.1',
'bodysubtype' => 'PLAIN',
'_prefix' => '1.1.1',
'bodysize' => '1971',
'bodytype' => 'TEXT',
'bodyMD5' => 'NIL',
'textlines' => '74',
'bodylang' => 'NIL',
'bodydesc' => 'NIL',
'bodyenc' => 'quoted-printable'
}, 'Mail::IMAPClient::BodyStructure' ),
bless( {
'bodyparms' => {
'charset' => 'utf-8'
},
'bodyextra' => 'NIL',
'bodyid' => 'NIL',
'bodydisp' => 'NIL',
'_id' => '1.1.2',
'bodysubtype' => 'HTML',
'_prefix' => '1.1.2',
'bodysize' => '23364',
'bodytype' => 'TEXT',
'bodyMD5' => 'NIL',
'textlines' => '331',
'bodylang' => 'NIL',
'bodydesc' => 'NIL',
'bodyenc' => 'quoted-printable'
}, 'Mail::IMAPClient::BodyStructure' )
],
'bodyloc' => 'NIL',
'bodylang' => 'NIL'
}, 'Mail::IMAPClient::BodyStructure' ),
'1' => bless( {
'bodyparms' => {
'boundary' => '----=_NextPart_001_EA96_2BF8DEDE.32622D51'
},
'bodyextra' => undef,
'bodydisp' => 'NIL',
'_id' => 1,
'bodysubtype' => 'related',
'_prefix' => 1,
'bodytype' => 'MULTIPART',
'bodystructure' => [
$VAR1->{'PartsIndex'}{'1.1'},
bless( {
'bodyparms' => 'NIL',
'bodyid' => '<5dff39db-e81c-4410-be75-8662564fd328>',
'bodyextra' => 'NIL',
'bodydisp' => 'NIL',
'_id' => '1.2',
'bodysubtype' => 'jpeg',
'_prefix' => '1.2',
'bodysize' => '14406',
'bodytype' => 'image',
'bodyMD5' => 'NIL',
'bodylang' => 'NIL',
'bodydesc' => 'NIL',
'bodyenc' => 'base64'
}, 'Mail::IMAPClient::BodyStructure' ),
$VAR1->{'PartsIndex'}{'1.3'},
bless( {
'bodyparms' => 'NIL',
'bodyid' => '<717f2ef4-f795-4d1c-87cc-283c9b0a59b0>',
'bodyextra' => 'NIL',
'bodydisp' => 'NIL',
'_id' => '1.4',
'bodysubtype' => 'gif',
'_prefix' => '1.4',
'bodysize' => '2912',
'bodytype' => 'image',
'bodyMD5' => 'NIL',
'bodylang' => 'NIL',
'bodydesc' => 'NIL',
'bodyenc' => 'base64'
}, 'Mail::IMAPClient::BodyStructure' )
],
'bodyloc' => 'NIL',
'bodylang' => 'NIL'
}, 'Mail::IMAPClient::BodyStructure' ),
'1.2' => $VAR1->{'PartsIndex'}{'1'}{'bodystructure'}[1],
'1.1.2' => $VAR1->{'PartsIndex'}{'1.1'}{'bodystructure'}[1],
'2' => bless( {
'bodyparms' => {
'name' => 'BKD-7361945220.pdf'
},
'bodyid' => 'NIL',
'bodyextra' => 'NIL',
'bodydisp' => {
'attachment' => {
'filename' => 'BKD-7361945220.pdf'
}
},
'_id' => 2,
'bodysubtype' => 'octetstream',
'_prefix' => 2,
'bodysize' => '47540',
'bodytype' => 'application',
'bodyMD5' => 'NIL',
'bodystructure' => [],
'bodylang' => 'NIL',
'bodydesc' => 'NIL',
'bodyenc' => 'base64'
}, 'Mail::IMAPClient::BodyStructure' ),
'1.4' => $VAR1->{'PartsIndex'}{'1'}{'bodystructure'}[3],
'1.1.1' => $VAR1->{'PartsIndex'}{'1.1'}{'bodystructure'}[0]
},
'_prefix' => 'HEAD',
'PartsList' => [
1,
'1.1',
'1.1.1',
'1.1.2',
'1.2',
'1.3',
'1.4',
2
],
'bodytype' => 'MULTIPART',
'bodystructure' => [
$VAR1->{'PartsIndex'}{'1'},
$VAR1->{'PartsIndex'}{'2'}
],
'bodyloc' => 'NIL',
'bodylang' => 'NIL'
}, 'Mail::IMAPClient::BodyStructure' );
As you can see none of the values are guaranteed to be part of every part on the PartsIndex and some them are nested.
variable of interest for each PartsIndex item:
bodytype
bodysubtype
bodyenc
Parse mail messages with Courriel:
use strictures;
use Mail::IMAPClient qw();
use Courriel qw();
sub walk_parts {
my ($obj, $callback) = #_;
if ($obj->is_multipart) {
for my $part ($obj->parts) {
walk_parts($part, $callback);
}
} else {
$callback->($obj);
}
}
my $imap = Mail::IMAPClient->new(
…
) or die $#;
my $folders = $imap->folders
or die $imap->LastError;
$imap->select('INBOX')
or die $imap->LastError;
my #messages = $imap->messages
or die $imap->LastError;
for my $id (#messages) {
my $raw = $imap->message_string($id)
or die $imap->LastError;
my $email = Courriel->parse(text => $raw);
walk_parts $email, sub {
my ($part) = #_;
my $content = $part->content;
my $type = $part->mime_type;
}
}
I tried using a couple of prebuilt modules but they had too many dependencies and was hard to work with. This solution adds no dependencies beyond the original. I also had issues with the dependencies for libMagic, see above, and I did not want anyone who uses my program to have to deal with that issue either.
You have to call decode twice once for the main parent, and again for each child. Since this $imap->get_bodystructure($msg); contains all the information you need why add dependencies where none are needed. It took many many hours to figure out how to decode it manually, but it was worth it.
You can add whatever decoders you want to the decode() subroutine. I only need to decode the text/html and base64 encoded versions there of. The IMAPClient functions give you a list of all parents and children so you don't have to go making a list by yourself. The tricky part is you can have any number of parent each with any number of children, but only the children contain useful data. The parents can be ignored, since many of their values are blank,undef, or 'NIL' (literally). In fact a vast number of variables have the value of 'NIL'. Even ones that the email client could have answered for the user like bodyMD5 and bodylang are USUALLY equal 'NIL'. Due to the overwhelming use of 'NIL' parsing and using other fields may prove futile. Depend on your imap server and the people you recieve email from you mileage may vary.
If you have further questions leave a comment.
use Mail::IMAPClient;
use MIME::Base64;
use MIME::Parser;
sub decode {
($process, $imap) =#_;
if ($process->bodytype eq "TEXT") {
print "\n Text SubType:".$process->bodysubtype;
if ($process->bodyenc eq "base64") {
return decode_base64($imap->bodypart_string($msg,$process->id));
}
elsif (index(" -7bit- -8bit- -quoted-printable- ",lc($process->bodyenc)) !=-1 ) {
return $imap->bodypart_string($msg,$process->id);
}
print "\n==========Insert new decoder here============";
print "\n".$imap->bodypart_string($msg,$process->id);
print "\n=================================================";
}
return "";
}
#insert your login code with credentials here
$imap->select( $sfolder )
or die "Select '$Opt{sfolder}' error: ", $imap->LastError, "\n";
my #msgs = $imap->messages or die "Could not messages: $#\n";
foreach $msg (#msgs) {
my $raw = $imap->message_string($msg)
or die $imap->LastError;
$struct = $imap->get_bodystructure($msg);
#MULTIPART is a container designation and does not contain anything useful by itself.
#However it will still process all of the children that have content
if ($struct->bodytype ne "MULTIPART") { print "\n BodyEnc:".$struct->bodyenc();}
$rDecode=decode($struct,$imap);
#do not insert blanks.
if ($rDecode ne "" && (length($rDecode)>2)) {push(#mail,$rDecode); }
foreach $dumpme ($struct->bodystructure()) {
if ($dumpme->bodytype() eq "MULTIPART") {next;}
$rDecode="";
$rDecode=decode($dumpme,$imap);
#do not insert blanks.
if (($rDecode ne "") && (length($rDecode)>2) ) {
push(#mail,$rDecode); }
}
}
You need a MIME parser. Unfortunately, even then, you will need some normalization of your own, because there are multiple ways to represent the same data in MIME.

Enable Cache plugin for ZFDebug

I'm developing a web-site with Zend Framework and I wish to use ZFDebug.
I followed the installation instructions, described here, but I don't initialize Zend_Cache in the bootstrap (define cache manager settings in section of configuration file).
So, my bootstrap section for ZFDebug looks similar to this:
if ($this->hasPluginResource("cachemanager")) {
$this->bootstrap("cachemanager");
$cache = $this->getPluginResource("cachemanager")->getCacheManager()->getCache("default");
$options["plugins"]["Cache"] = array("backend" => $cache->getBackend());
}
$debug = new ZFDebug_Controller_Plugin_Debug($options);
With this code ZFDebug shows 'Cache' item in menu, but it is not clickable. What should I do to make ZFDebug show cache info? I use Xcache as Zend_Cache backend.
I only started playing with ZFDebug this morning but my Boostrap.php init's the cache and registers it first. In the _initZFDebug i call call the registry to get the cache.
protected function _initCache()
{
$frontendOptions = array(
'lifetime' => 3600*24*5, // cache lifetime of 5 days
'automatic_serialization' => true,
'logging' => false,
'caching' => true
);
$backendOptions = array(
'cache_dir' => './../data/cache/', // Directory where to put the cache files
'hashed_directory_level' => 2
);
$flickrFrontendOptions = array(
'lifetime' => 3600*24*5, // cache lifetime of 5 days
'automatic_serialization' => true,
'logging' => false,
'caching' => true
);
$flickrBackendOptions = array(
'cache_dir' => './../data/flickr/', // Directory where to put the cache files
'hashed_directory_level' => 2
);
// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory(
'Core',
'File',
$frontendOptions,
$backendOptions);
Zend_Registry::set('cache', $cache);
$flickrcache = Zend_Cache::factory(
'Core',
'File',
$flickrFrontendOptions,
$flickrBackendOptions);
Zend_Registry::set('flickrcache', $flickrcache);
}
protected function _initZFDebug()
{
if ($this->hasOption('zfdebug'))
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
$options = array(
'plugins' => array('Variables',
'Database' => array('adapter' => $db),
'File' => array('basePath' => $this->hasOption('zfdebug.basePath')),
'Cache' => array('backend' => Zend_Registry::get('cache')->getBackend()),
'Exception')
);
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
}