Using `mail` to locally send messages to yourself - bash

I have a daemon that executes some commands every two days. When it encounters any error, I want it to notify me. I know that bash can look up the /var/mail/user and tell me if there any new messages in this file. But I never used messages before. I think I have to use the mail command to do that.
However when I try to look up information about the usage of the command, I only read about sending actual emails, not local messages to users. So how would I send a message to myself, so that when I execute mail I'd get You have new mail.

If all you need is to be notified by your automated task, you could use something else than mails. Chatbots, for instance.
I personally use nimrod : https://www.nimrod-messenger.io
It's messenger only but other chat systems are planned.

Related

Email batches via AWS SES, ideas?

I have an SaaS application where each paying customer may have thousands of members they may want to send emails to every now and then.
For now, simple BCC sending via AWS SES have done the trick, but now I am looking at sending personalized emails so I must be able to send the emails one by one.
SES does not have any queue system as per my knowledge, you must make an API call per email. In short, it takes forever to send a batch (my limit is 14 per second), and the user cannot close the page while it is executing (even AJAX calls stop executing if you leave the page, am I right?).
I was thinking of building a system where I store the emails in a database table and then either:
1) Use a CRON that executes every 5 seconds or so, grab a few emails and send them.
2) Execute an AJAX script each 5 seconds that grabs the emails for said logged in customer in a batch ONLY and send them out, but again, if the customer logs out while it executes chances are that specific a batch is interrupted (the remaining ones would still keep sending the next time the customer logs in).
Does any have any better ideas? Or, which of the two above would be preferred?
You should use templates and the SendBulkTemplatedEmail endpoint that AWS introduced a few months ago: https://aws.amazon.com/blogs/ses/introducing-email-templates-and-bulk-sending/.
That way you can send up to 50 personalized emails with a single SES API call. So 700 with 14 calls.
You shouldn't consider queuing them up in a user's browser and sending them by making a series of AJAX requests though. You should only send one Ajax request to start a job. In most server-side languages (any I can think of) you can respond to an HTTP request and still continue doing processing after responding. You can also implement a progress checker in a multitude of ways.
Use a cronjob that sends to the SES SMTP server. This way you can personalize the emails and also control how many emails to send. Your cronjob can sleep in between each batch of emails.
You can use celery to run background job. A user submits a request on a webpage which starts a background job through celery. The background job take care of sending emails. Once sending emails is completed, inform the user by email.
http://www.celeryproject.org/

How to stop OSX messages app storing every sent SMS?

I have written a simple applescript script to go through a list of phone numbers and send an SMS using Messages app on OSX. This all works great but Messages stores every sent message and I don't want it to do that. I've unchecked the only option in Messages preferences to not save the messages on exit but this seems to do nothing. It still saves the messages.
I don't mind adding to my apple script to 'tell' messages to delete the messages but I don't know how to do this. Any ideas?

Is there a Sinch example using an inbox?

Sinch seems to serve the purpose find for sending messages but is there an example, perhaps using Parse, where missed messages accumulate in an inbox and allow for responding to the missed message and keeping the thread of messages?
The messages will be delivered to the client as soon as you launch the app, then you can save it to parse if you like.

Trigger a shell script on mail arrival

How can I trigger a shell script on an email arrival that extracts the mail in a text file? I want to extract the information in the mail, process it to determine the request and send an automated response to that request. The mail will basically consist of a data request and the response will have the requested data in a text file attached to it.
Look into the documentation of your MTA (mail transfer agent). Many of them allow to run scripts or hooks when mail arrives and certain other conditions are met.
If you're using Linux and want a pure client solution (i.e. independent of the mail server software), then you should look at procmail. The documentation contains lots of useful tips and hints how to set up the tool (like performance considerations) and how to properly set up the environment so your script executes correctly.
It also contains examples like a service which responds to "ping" mails.

Ncqrs: How to store events as part of test set-up

How do I store events as part of setting up my tests?
Currently I'm initializing application state by sending commands like this:
Given some commands were sent
When sending another command
Then some events should have been published
I'm using ICommandService.Execute() to send the Commands in the Given and When parts.
Since commands can be rejected by the domain, I wouldn't want to rely on them. I'd rather set up my application state by simulating events like this:
Given _some events_ occurred
When sending a command
Then some events should have been published
How do I push the events from Given into the event store so that they can be replayed during handling the "When" part?
Thanks
Dennis
Have been given the answer on the mailing list and will add this for further reference:
I was using an old version of Ncqrs. The current version exposes Ncqrs.Eventing.Storage.IEventStore.Store() which takes an event stream and can be uses during test set-up just as needed.

Resources