I am looking for the syntax to show both message headers (to, from, subject, date), as well as message size when issuing an IMAP command via OpenSSL or telnet.
Currently, I am using:
. fetch 1:* (body[header.fields (from to subject date)])
and
. fetch 1:* (rfc822.size)
I am using these as separate commands, but I was wondering if there is a way to integrate them into a single command. I haven't been able to figure it out myself and wonder if anybody here knows of a way.
You should be able to put both data items in the list:
. fetch 1:* (rfc822.size body[header.fields (from to subject date)])
Related
Two-fold issue: 1) Trying to download attachments from Outlook emails using win32 in Jupyter Notebook 2) I get notifications of different lessons and resources by phone. Then I usually, send the URL to the resource to my email to organize later on. Is there a way to use Jupyter Notebook to grab these emails and store them in an excel file? Here is the lesson I am trying to follow currently: https://towardsdatascience.com/automatic-download-email-attachment-with-python-4aa59bc66c25 . And here is my code:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.items
message = message.GetFirst()
attachments = message.Attachments
attachment = attachments.Item(1)
attachment_name = str(attachment).lower() attachment.SaveAsFile(path + '\\' + atttachment_name)
exit
You never check that a message has attachments (message.Attachments.Count > 0) and you assume that you get a particular message from the Inbox: can either get the currently selected message (Application.ActiveExplorer.Selection collection) or you need to search for the particular message using Items.Find/FindNext or Items.Restrict. Items.GetLast will give some undetermined item.
Thirdly, the line message = message.GetFirst() was probably meant to be message = messages.GetFirst(). Still won't work, but at least it won't blow up because message variable is uninitialized.
Accurately, I want to filter logs and send some warning email.
Firstly, I tried ommail, but unfortunately, this module only support mail server which do not need authentication, but my mail server needs.
So I tried to use omprog, I wrote a python script to logon to my mail server, it will recieve one parameter which is the log and send it as mail body.
Then I got the problem, I cannot pass the log to my script, if I try like this, $msg will be recognized as a string .
if $fromhost-ip == "x.x.x.x" then {
action(type="omprog"
binary="/usr/bin/python3 /home/elancao/Python/sendmail.py $msg")
}
I tried to search the official doc.
module(load="omprog")
action(type="omprog"
binary="/path/to/log.sh p1 p2 --param3=\"value 3\""
template="RSYSLOG_TraditionalFileFormat")
but in the sample, what they are using is a string "p1", not a dynamic parameter.
Can you please help? Thanks a lot!
The expected use of omprog is for your program to read stdin and there it will find the full default RSYSLOG_FileFormat template data (with date, host, tag, msg). This is useful, as it means you can write your program so that it is started only once, and then it can loop and handle all messages as they arrive.
This cuts down on the overhead of restarting your program for each message, and makes it react faster. However, if you prefer, your program can exit after reading one line, and then rsyslog will restart it for the next message. (You may want to implement confirmMessages=on).
If you just want the msg part as data, you can use template=... in the action to specify your own minimal template.
If you really must have the msg as an argument, you can use the legacy filter syntax:
^program;template
This will run program once for each message, passing it as argument the output of the template. This is not recommended.
if omprog script is not doing or not saving to a file the problem is that :
rsyslog is sending the full message to that script so you need to define or use a template
your script needs to listen to and return an
example in perl whit omprog
#my $input = join( '-', #ARGV ); ///not working I lost 5 hours of my life
my $input = ; now this is what you need
Hope this what the perl/python/rsyslog community needs.
Is this possible to generate a new Zabbix event from a Ruby script? I was suggested to use zabbix_sender script, but I couldn't find any example.
Also, I couldn't find any API related to the events creation.
First of all create some item of type zabbix trapper and then you can send some values to its name by zabbix_sender. You can send one value, or more collected data with timestamps. Here are docs.
Alternatively you can write own zabbix trap sender. Protocol is quite easy. I done the same in Python... no external commands.
Zabbix API does not allow item value updates by design.
I have investigated couple options* and my preferred way to update Zabbix item value from Ruby is using this approach found in miyucy's gist:
Example with simple error handler:
s = Zabbix::Sender.new 'zabbix_server', 10051
zabbix_resp = s.send('host', item_key, value)
if zabbix_resp["response"] != "success" or zabbix_resp["info"].split(';')[1] != " failed: 0"
puts "error: zabbix responded with #{zabbix_resp} when trying to update #{item_key}"
end
*One example of alternative way - calling zabbix_sender binary
I know I can easily get messages inside
[CustomMessages]
AdditionalIcons=blablabla
using this code:
ExpandConstant('{cm:AdditionalIcons}');
which gets the AdditionalIcons string message. However, how can I get messages inside this?
[Messages]
ButtonNext=huhu
ButtonInstall=bubu
What I need is to get the ButtonNext, ButtonInstall and other values, and it is NOT possible to get those values using code like this:
ExpandConstant('{cm:ButtonNext}');
How can I query those values?
Related links
Inno Setup Script tips
Try
SetupMessage(msgButtonNext);
In general, the name of the constant to use (in this case msgButtonNext) is msg + the name of the message (string concatination).
I am trying to incorporate this script here (http://snippets.dzone.com/posts/show/7530), yet i'm no ruby wizard.
Right now it pulls down mail that I want with the local_file name, but was wondering if its possible to have it pull it down and save it by the 'message subject title + date of message'. When I try using mail.date, I get a longer than normal string, and can't convert it with Time.parse().
For instance, right now it pulls down an attachment as 103134.htm, which has no significance to me, and I'd rather have it be "Logs from Blah - 11/12/2009.htm" since it pulls the subject and date from the original message instead of the attachment local_name.
Any help would be greatly appreciated!
Thanks!
mail.date already returns a Time object, so it is not required that you parse it again. Instead use mail.date.strftime("%m/%d/%Y") to get your desired output