How can I set triggers for sendmail? - unix

If my email id receives an email from a particular sender, can I ask sendmail to trigger a different program and pass on the newly arrived email to it for further processing? This is similar to filters in gmail. Wait for some email to arrive, see if it matches the criteria and take some action if it does.

This is what Procmail is for.
Set Sendmail up to use procmail as the mail delivery agent (MDA), or set up your .forward to pipe stuff through procmail. (See the man page.)
Then you can write your .procmailrc to do all sorts of things along these lines.
This filter predates gmail. Still useful if you're running a mail server.

are you talking about email clients? If so then you can set rules in outlook and I am sure there mustbe ways in other email cleints too!! If u are asking something else. sorry

ok. then I suggest Colins method.. I use cron to monitor emails (for a particluar domain) and send text messages as alerts!. Similar to what you are asking!

We handle this by having a cron process running on the mail server which watches the inbox directory and scans any new messages (files) every 10 minutes or so.
When the process finds an email of interest, it fires the information off to another process which then reacts to the new message (and, in our case, removes the message from the inbox).
--edit--
Finding the email inbox depends on your implementation - check the 'manual' your version of sendmail for details - we direct incoming email to a special directory or have parameters to work out the inbox details. I don't feel it would be useful to be more specific as the answer to 'where is the inbox' is 'it depends'.
As for the pattern to search for - we decode the email message (a text file) into a DOM that we can manipulate. For example, we can then look for specific words in property 'subject'.

Related

telegram use schedule message

I want to schedule a telegram bot message to be sent at a specific unixtime.
As from telegrams official api (https://core.telegram.org/api/scheduled-messages) that should be possible by setting the schedule_date flag.
To schedule a message, simply provide a future unixtime in the schedule_date flag of messages.sendMessage or messages.sendMedia.
However I was not able to set that flag. To be more precisely, I do not even know how to set a flag, or if I am using the correct api.
What I have tried is to use the api directly via the browser (could use curl as well) like so: https://api.telegram.org/botBOT:TOKEN/sendMessage?chat_id=ID&text=Test&schedule_date=1653503351
I also did not find any way to access this flag via https://pypi.org/project/pyTelegramBotAPI/#description https://telepot.readthedocs.io/en/latest/#send-a-message, nor https://github.com/nickoala/telepot.
I want to implement this feature in a python environment, but any working suggestion would be much appreciated.
EDIT:
I decided to save the intention to send a telegram bot message at a certain unixtime in a database. I then create an infinite loop that checks if there are any unsent messages before the current timestamp. If the loop detects such a message it sends the message and sets a flag, that that message has been sent.
And as promised, here is a fully dockerized example of that behaviour in action: https://github.com/Sokrates1989/nameTheCountDown-lightweight
It creates a bot that you can pass a name and the duration. Once the duration has passed it sends a message with the passed name. Basically a simple countdown that you can give several names, that run simltaniously. As it is a telegram chat, you can modify the way you are informed about the end of a countdown by modifying the notificaiton of that chat.
And here is the Bot in action: http://t.me/NameTheCountdownBot
We can't do this by bot API itself, and there's no schedule_date parameter in sendMessage method:
https://core.telegram.org/bots/api#sendmessage
And what you've read is for Telegram clients, not bot API consumers.
If you don't really need unixtime, you can simply create a table for scheduled messages with a text, chat_id and a publish_time column (like 22:15), and run a command every minute to look if there's a message for current time to send. Then send the message and delete the record.
Note that the python-telegram-bot library has a built-in solution for scheduling tasks: The JobQueue. This feature is based on the APScheduler library, which you can ofc also use without python-telegram-bot.
Disclaimer: I'm currently the maintainer of python-telegram-bot.
https://core.telegram.org/method/messages.sendScheduledMessages
Now you can send scheduled messages right away

Why SMS sending is failing using plivo in R?

I am trying to use R script to send SMS internationally. I am using correctly Auth ID and Token, both numbers are verified. But I haven't bought any number from "Plivo". Is this the reason my message is not sent?
The code is getting compiled without any error. But no SMS is sent or received. I am sharing my code below:
#!/usr/bin/env Rscript
library(httr)
AUTH_ID="**************"
AUTH_TOKEN="**************************"
message<-"Eddie is confirming the message"
url="https://api.plivo.com/v1/Account/**************/Message/"
POST(url,authenticate(AUTH_ID,AUTH_TOKEN),body=list
(src="+966123456789",dst="+4912345678910",text=message))
Can anybody please tell me that what could be the possible reasons that why message sending is not happening even the source code is correct?
But I haven't bought any number from "Plivo"
The answer is:
To send an SMS with Plivo, you need a Plivo bought number.
Obvious logic:
If this was not the case, anyone could send messages from any "verified" phone numbers?
If you meant verified as in "account verified":
This is not what Plivo is used for, you need to check if your Mobile Carrier is providing an accessible internet accessible API (I doubt it.) If you need to use sim-linked numbers, you can always use modems and AT commands, but it's fairly unreliable.
I think you should buy a $1 Plivo number, unless you need it to validate gmails or things of such.

Setup R alert when long process is Finished

I'm running a really long process and it would be great if there was a way to get R to Call, Email or Text me when its finished. Is there a way to setup an R-email script to be run when a program terminates or perhaps something that might employ IFTTT to send me a text message or Call in case I'm sleeping.
I'm using RStudio as my IDE so maybe there is such a feature through there.
If there is a way to track progress that would be nice too, but not 100% required
From this article:
http://alicebrawley.com/getting-r-to-notify-you-when-its-finished/
My general solution is to combine the R package mail, written by Lin
Himmelmann, and variations on an IFTTT (If This, Then That) recipe. I
use mail to send an email using functions in R, then IFTTT to notify
me immediately of that particular email.
Once you’ve installed mail, use the following functions to send
yourself an email when your code is completed.
#Have R email you when it's done running.
###Calculating - your wish is R's command.
library(mail)
#Send yourself an email - specify your preferred email address, subject, and message. The password is fixed at "rmail".
sendmail("xxxxx#xxxxx.com", subject="Notification from R", message="Conditions finished running!", password="rmail")
You can then use IFTT triggered by the email.
If you're sleeping next to your computer, consider also: Is there a way to make R beep/play a sound at the end of a script?

How to get test agent's state and queue length

does a codedui tests agent exposes an api to get information
about it's status in real time?
if so where can i find details about it and purhapse code examples?
edit:
i've found a way to get some information on test agent via command line (link in the comment section),
still would love to know id there's an api to enable other types or actions, specifically restarting the agent
Looks like there is a lot of functionality to be accessed through TestAgentConfig.exe. I found an MSDN blog post that goes into some details on the feature.
Specifically, to start or stop the agent: "Start/Stop service - sc \machinename stop vsttagent ; sc \machinename start vsttcontroller. If the agent and controller are in different domain, you can use IP instead of machine name."

NopCommerce will not mark off messages as sent in message queue and keeps on flooding with E-mails

I have just installed nopcommerce 1.9 and now configuring it.
Inputed all the correct settings for the SMTP (Host, port etc.) and the test E-mail arrives fine to any address I tested it with.
However should I fill in the contact form or have a new user sign-up the store can't stop sending the same message over and over again to the default store E-mail address or to that of the user. Keeps sending the welcome to the store E-mail for those that signed up or the message body of the contact form etc. To stop it I have to go to message queues and delete the message(s) from there manually, these messages are are flagged as unsent! Even though they have been sent out many times obviously.
So it re-sends everything being sent by the store non stop even though the message went out fine the first time.
Anyone know why it's doing this? Have confirmed I have correct settings for the smtp with my webhost provider, nothing in mail error log of worth.
Thanks...
If you run nopCommerce 1.90 under medium trust, please follow the next steps in order fix the issue when customers keep receiving mails:
Open \Libraries\Nop.BusinessLogic\Messages\MessageService.cs file
Find UpdateQueuedEmail method
Replace
if (!_context.IsAttached(queuedEmail))
_context.QueuedEmails.Attach(queuedEmail);
with
if (!_context.IsAttached(queuedEmail))
_context.QueuedEmails.Attach(queuedEmail);
_context.ObjectStateManager.ChangeObjectState(queuedEmail, System.Data.EntityState.Modified);
Recompile the solution
...or simply redownload the latest version here (the version is still 1.90)

Resources