PHPMailer DEBUG OUTPUT without Attachment data - debugging

I am using PHPMailer (v 6.6.0) and would like to record meaningful debug information. As noted in other threads, there appears to be no means to exclude message content/body and attachments from the Debug output. I've looked at the feasibility of using the $mail->Debugoutput = function($str,$level){} callback to filter the data, but don't see a way to identify the message content or attachment data from the header info that I'm really interested in - SMTP connection info and message header.
Does anyone have a solution or clue as-to how to parse out the message content (ideal) and attachment (MOST important) data from the Debug output?
My suggestion would be to remove the message and attachment content from the LEVEL 1 and 2 logging and provide them only as an option with another LEVEL.
Thanks in-advance.
-jmd

Related

JSON ordering and logging response/request body in envoy

I am using envoy proxy in my application and I am trying to print logs in these three ways:
In fixed ORDERING JSON format
Need to add request and response body of the request to log
Can we add a route level logging (enable/disabling), not with Lua?
All below scenarios log level is added in listener filter in my application.
#1:
I am able to add stdout access logging and able to print logs in JSON format but not able to order them in a fixed format like first key should be response code and so on. Each time JSON log prints order of keys changes.
#2: In my logs how can I add my request and response body? I tried to find formats supported by the envoy but had no luck.
What extra parameters do I need to in json_format to get the body?
json_format": {"protocol": "%PROTOCOL%","duration": "%DURATION%","my_custom_header": "%REQ(MY_CUSTOM_HEADER)%"}
#3: Can we add route level logging in envoy and also enable/disable on route level? I read the documentation but was not able to find anything.
In Lua we can add like below on route level can we do without Lua/another plugin?
envoy.filters.http.lua:
"#type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute
# name: bye.lua
disabled : true
For #1, I have same question with you on #1. It's terrible that we can't control JSON order for the access log.
For #2, I don't think print request body is a good idea. You can try to log request body in your application and track envoy log and your application log with the same x-request-id.
For #3, I don't have further knowledge for lua filter. But enovy access log itself has many fields for UPSTEAM and DOWNSTREAM.
Hope you have already resolved the issue and share back : )

Laravel 5.7: Can I programmatically force Slack to not split longer message into two or more?

Funny case, I wrote a Slack Notification that is being sent each time cron job cleans some files.
One night the list of cleaned files was long enough that slack split that into two separate posts. There would be no issue except of the fact that I wrapped the content in a pre tags via:
public function toSlack()
{
return (new SlackMessage)
->success()
->content(sprintf('*Garbage Collector*```%s```', $this->message));
}
By splitting a message the end result was that the first slack message had opening pre tag but didn't have a closing one, while the second one didn't have opening one and did have the closing one. Visual result was that both messages where not displayed in the plain text.
Desired effect (occurs when the content is not too long):
Behaviour I consider as a bug that I don't know how to fix (occurs
when the content is too long):
Second part:
Stub I use with str_replace below:
Garbage Collected
Environment: {app_env}
Date: {date}
{separator}
List of files deleted from the temporary directory:
{garbage}
{separator}
Reason: {reason}
Space recovered: {garbage_size}
Have a nice day!
Can I somehow fix this within Laravel or is it up to boys from Slack?
After a bit of testing here is list of relevant limits for creating messages in Slack:
Messages will be automatically split: > 4.000 chars in text (undocumented)
Messages will be truncated: > 40.000 chars in text (Source)
Attachment will be truncated: > 8.000 chars in attachments / text (undocumented)
As far as I know that behavior can not be changed and is the same for all the different ways to send a message:
via Web API (chat.postMessage)
via Incoming Webhook
as response to a Slack request (slash / interactive message)
Here are a few ideas for a workaround:
Split the text in your app and send them as separate messages to Slack
Generate the text so that the cut at 4.000 will always be outside any formatting tags
Upload the whole text as text snippet with file.upload. Slack will then automatically show a preview of the text and the user can open the whole thing by clicking on it.
I would suggest 3. since its more user friendly.
Also see this documentation for an overview of all known text limits in Slack messages.

Is there is possible way to return error message in http response (HandleHttpResponse processor)

I have a simple process, which starts with HandleHttpRequest then goes PublishKafka. After that, on success status I return responce code 200. On failure I want to return response with code 500 and with error message in the content. I have tried many ways, but I still don't know how can I do it. Is there is any possible way?
UPDATE:
When PublishKafka fail with some error message I need to send this error message in http response. I don't know how can I get this error message. There is no appropriate attribute in the flowfile. I have wanted to put the message in flowfile content. One of the possible resolutions is to use nifi-api or bulletin, but maybe there is more easiest way to do it.

No user defined transport headers in pulled messages from queue OSB JMS WLS

im facing a problem with my jms messeages.
Case is:
in my mainPS i give an employeeId on request which routes to BS to get employees with emploeeId >= than given. Response is employees collecion.
On response action in mainPS I loop through whole collection and id like to add to JMS queue one by one employee as simple message. In every loop iteration im seting user-defined transport header in if statement as msgName 'even' or 'odd' depends on employeeId on Outbound Request. On loged result i can see that headers have added properly.
Then (still for every employee) I publish my JMS-BS which adds message to queue.
When I want to pull my messages in JMSConsumerPS there are no any transport headers which i have added. Consumer has Get All Headers property set as 'YES'.
Im logging in consumer my whole
$inbound/ctx:transport
and what i get is:
<con:transport>
<con:uri>myURI</con:uri>
<con:mode>request</con:mode>
<con:qualityOfService>best-effort</con:qualityOfService>
<con:request xsi:type="jms:JmsRequestMetaData" xmlns:jms="http://www.bea.com/wli/sb/transports/jms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tran:headers xsi:type="jms:JmsRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
<jms:JMSDeliveryMode>2</jms:JMSDeliveryMode>
<jms:JMSExpiration>0</jms:JMSExpiration>
<jms:JMSMessageID>ID:<834866.1398327222060.0></jms:JMSMessageID>
<jms:JMSPriority>4</jms:JMSPriority>
<jms:JMSRedelivered>false</jms:JMSRedelivered>
<jms:JMSTimestamp>1398327222060</jms:JMSTimestamp>
<jms:JMSXDeliveryCount>1</jms:JMSXDeliveryCount>
</tran:headers>
<tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">UTF-8</tran:encoding>
<jms:message-type>Text</jms:message-type>
</con:request>
Thanks for help.
Just a guess.
I was setting transport header in in-correct place. I had a "publish"
action in the proxy and I was setting transport header just before the
publish action. I moved the "transport header setting" to be done
inside the "publish" action/task . Now it works as expected.
Taken from https://community.oracle.com/thread/2155298?tstart=165, link most likely will be dead soon enough - Oracle community ...
Thank you very much for that. That was almost same issue. What I did was movig "transport header setting" into request action of published BS. Thing is i have tried it before asking but had no idea why it didnt work. Probably the reason could be that i turned on pass all headers through pipeline that time [?]. Had no idea if that can make such a mess. Thanks for replaying.

Selecting an outgoing mail message programmatically

Here's what I'm attempting to do: Let's assume that you are in mail and create a New blank mail message, then enter some data into it, such as body copy, etc. (in my case, the message was created through scripting bridge using the "Mail Contents of this Page" from safari... the main purpose of this process for my application.)
From my application, I want to select that message and assign it to:
MailOutgoingMessage *myMessage;
so that I can programmatically add recipients. I've tried several ways of doing this which seemed logical, but so far I haven't found the right combination, and the header file doesn't seem to be very clear to me (I'm new to scripting bridge.)
My initial thought was to try this:
mailMessage = [[mail outgoingMessages] lastObject];
Which should grab the last outgoing message created. It seems to work in that I am able to add recipients to mailMessage (though there have been a few times that I received unexpected results when multiple outgoing messages exist, such as adding the recipients to the wrong message) but attempting to log the subject line of the message:
NSLog(#"Subject = %#",[mailMessage subject]);
always returns NULL even though there is a subject clearly viewable in the subject field of the message. NULL is returned for any other parameter as well.
I'm gathering it must be a problem with my assignment to mailMessage above, because the only time I receive a NULL for message properties (or receive unexpected results) is if I try to point mailMessage to an existing outgoing message. If I create the mail message with scripting bridge, then I can retrieve all of the properties correctly.
Does anyone understand the hierarchy of the Mail scripting enough to tell me why I am getting NULLs for the parameters using the above assignment for mailMessage? What would the simplest way be go grab my message so that I can add recipients and later call the:
[myMessage send];
method? Any insight would be helpful. I've spent a week going through the mail.h header file and am quite literally at a loss as to what else to try at this point.
There's no way to (send, get or set the properties of the outgoing message) that the user or Safari has created.
It's a bug (it stopped working since Mac OS X 10.4), or some privacy/security considerations.

Resources