message: move The DestinationId parameter is missing - php

I want to move mails (copy or move), I use
Microsoft\Graph\Graph , guzzlehttp/guzzle and php
I am missing the DestinationId parameter
here is the query I am using
$graph->createCollectionRequest("POST","/users/xxx#xxxx.com/mailFolders/$inbox_id/childFolders/$folder_id/messages/$message_id/move/")->execute();
and I don't know where to put DestinationId.
here is the error code I got
{
"code":"ErrorInvalidParameter",
"message":"The value of the parameter 'DestinationId' is empty."
}

I found
$mailBody = array( "DestinationId" => "$message_id");
$graph->createCollectionRequest("POST","/users/xxx#xxxx.com/mailFolders/$inbox_id/childFolders/$folder_id/messages/$message_id/move/")->execute()
->attachBody($mailBody)
->execute();

Related

Making my sender option to send attachment or not

Anybody have idea what happen with my sender? , trying to make an option to send attachment or not
if ($makassarid_setup['filesend'] == 1) {
$filepdf = file_get_contents($AddAttachment);
$mail->AddAttachment($filepdf);
}
Thats are from the MKSENDERS , the sender its self the $makassarid_setup came from the mks.setting.php as the config file, its have been included as the top of MKSENDERS file
as u see on if ($makassarid_setup['filesend'] == 1) {
it should be sending attachment if i have set 1 on the mks.setting.php file "filesend" => 1, (on mks.setting.php) , but it given me output when im execute the sender
PHP Notice: Undefined variable: AddAttachment in /home/ubuntu/workspace/DEATHhomo/MKSENDERS on line 125
PHP Warning: file_get_contents(): Filename cannot be empty in /home/ubuntu/workspace/DEATHhomo/MKSENDERS on line 125.
when im turn the "filesend" => 0, it send the email normally, without any error input, and the $filepdf is came from the mks.setting.php "filepdf" => "file/attachment/a.pdf", so it the filename not empty ofcourse, i would really appreciate any help from you.
Thanks Alot! :D
PHPMailer just needs the filename, not its contents, so it seems you want:
if($makassarid_setup['filesend']==1){
$mail->AddAttachment($filepdf);
}
if ($makassarid_setup['filesend'] == 1) {
$takeattachmentfromtheconfig = $makassarid_setup['filepdf']
$callingtheattachmentabove = file_get_contents($takeattachmentfromtheconfig);
$mail->AddAttachment($callingtheattachmentabove;
}
this is right?

What does the is_final parameter in xml_parse() do?

I'm working on creating a class for xml parsing, and need to use this method from PHP called xml_parse.
It has 3 parameters like so:
int xml_parse ( resource $parser , string $data [, bool $is_final = false ] )
According to the PHP manual is_final it means whether its the last piece of data sent in this parse, but what does this mean? does this something have to do with resource $parser? as far as I'm aware this function does not allow an input stream of data, thus my confusion.
Someone please explain what it does
is_final means that if you are parsing the last line of your $data you must set this parameter to true.
in addition there is a note in the Doc :
Entity errors are reported at the end of the parse. And will only show if the "end" parameter is TRUE
See the sample below from w3schools
<?php
$parser=xml_parser_create();
function char($parser,$data)
{
echo $data;
}
xml_set_character_data_handler($parser,"char");
$fp=fopen("test.xml","r");
while ($data=fread($fp,4096))
{
xml_parse($parser,$data,feof($fp)) or
die (sprintf("XML Error: %s at line %d",
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser)));
}
xml_parser_free($parser);
?>

Sorting Imap mailbox by date using ImapMailbox.php

I have a customer support system which creates emails when an email is received. I used to postfix and a special configuration to get a hold of the emails to add extra features.
For example I want to include attachments that were sent from an email. The system doesnt do this , but creates an email with the subject , so I can include the attachments by matching the subjects.
I used ImapMailBox.php to read through the email contents.
It all works fine but I am getting an issue fetching the last email, so I am gettign contents from any other email with the same subject , so I need to fetch the latest email.
$mailboxP = new ImapMailbox('{127.0.0.1:143/novalidate-cert}',POSTFIX_EMAIL,POSTFIX_PASSWORD,ATTACHMENT_DIR, 'utf-8');
foreach($mailbox->searchMails('ALL') as $mailId)
$mail = $mailbox->getMail($mailId);
$mailx=(array)$mail;
$att=$mailx['attachments'];
I have tried using usort to the object $mail , with a function like this
function
mysort($a,$b) {
return strtotime($a->date)-strtotime($b->date);
}
and to the array with a function like this
function mysort($a,$b) {
return strtotime($a['date'])-strtotime($b['date']);
}
I have also tried using imap_sort to $mail and $mailx , but none of this works.
errors I am getting
imap_sort() expects parameter 1 to be resource, array given
imap_sort() expects parameter 1 to be resource, object given
usort() expects parameter 1 to be array, object given
when passing an array I get undefined index date but it defined ..
Can anyone please be kind enough to point me in the right direction.
You can add a function like this on ImapMailbox.php :
public function searchMailsSorted($imapCriteria = 'ALL') {
$this->checkConnection();
$mailsIds =imap_sort($this->mbox,SORTDATE,1,SE_UID,$imapCriteria,$this->serverEncoding);
return $mailsIds ? $mailsIds : array();
}
And then use it in your code like this:
foreach($mailbox->searchMailsSorted('ALL') as $mailId)
{
///insert code here
}
The easiest way is to use Php rsort() function.
<?php
$emailId = rsort($mailbox->searchMails('ALL');
?>

Why php's soapCall gives string conversion error?

// Set username and password
$ih_soap_user= $this->config->item('interUser');
$ih_soap_pass=$this->config->item('interPass');
//echo $ih_soap_user.':P:'.$ih_soap_pass;
// Set soap namespace
$ih_soap_ns = 'http://www.interhome.com/webservice';
// Create new instance of SoapClient with the interhome web service URL
$client = new
SoapClient($this->config->item('interSoap'),array('trace'=>'1'));
// Create new soap header and set username and password
$header = new SoapHeader($ih_soap_ns,
'ServiceAuthHeader',
array('Username' => $ih_soap_user,'Password' =>
$ih_soap_pass),
true
);
// Prepare p// Prepare parameters
$params = array('inputValue' =>array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>array('House'=>'House'),
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'',
) );
try{
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
Hi guys..Any Idea why this call when I pass any not empty array, as for example ,as I made for 'HouseApartmentType', returns this error
A PHP Error was encountered
Severity: Notice Message:
Array to string conversion
Filename:
controllers/houses.php Line
Number: 269
And when it's only empty array or a string the soap call function is working... I need to pass array of options to one parameter....
LINE 269 is
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
This is probably solved already, but I also had problems with this and I thought I should post here when I finally found the solution. (The solution is not nusoap, it throws the same error.)
The error only seems to come from the soapCall call generation, it really is the Web Service that causes it. When you run __soapCall, it first asks the server which datatypes the parameters should have and then tries to comply. So if you try to feed an array when the service expects a string, it will do the array to string conversion when the request is generated.
i think you should look at the manual how a soapcall work:
$params = array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>'House', // changed to string instead of array
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'' );
i simplified the array and you should test it and look if this is the kind of result you are looking for.
Also look for ordering errors like the example shown in php.net

Need help with Swift mailer with Kohana wrapper

My current code is this
$swift = email::connect();
$swift->setSubject('hello')
->setFrom(array('alex#example.com.au' => 'Alex'))
->setTo(array('alex#example.com.au' => 'Alex'))
->setBody('hello')
->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));
$swift->send();
The email::connect() returns an instance of SwiftMailer.
As per these docs, it would seem that it should work.
However, I get an error
Fatal error: Call to undefined method Swift_Mailer::setSubject() in /home/user/public_html/application/classes/controller/properties.php on line 45
I've seen that email::connect() does exactly what the example code in the docs does. That is
include the correct file
return an instance of the library
What am I doing wrong?
Thanks
You're using a Swift_Mailer instance, not a Swift_Message like in the example you linked to.
I think you want something like this:
$swift = email::connect();
$message = Swift_Message::newInstance();
$message->setSubject('hello')
->setFrom(array('alex#example.com.au' => 'Alex'))
->setTo(array('alex#example.com.au' => 'Alex'))
->setBody('hello')
->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));
$swift->send($message);

Categories