Email events in Sinatra - ruby

I am working on a Sinatra web app that needs to save any email that it receives in a db (or do something else as soon as a mail is received). What is the best tool for this job? I was looking at eventmachine and it seems a bit complex. I was considering the mail gem but it doesn't trigger events when mail is recieved. One final query: To test such an app, do I need it to host it online? If not, then how to do I send emails to the app and test?
Thanks a lot,

So Sinatra is a web server. Email doesn't come in from HTTP requests, so you need a mail server to receive the emails and assuming you still want to handle them in your Sinatra app, fire a request at your app.
check out http://steve.dynedge.co.uk/2010/09/07/incoming-email-in-rails-3-choosing-the-right-approach/ for a few options (it's thinking rails, but you should be able to translate)

Related

Spring Catch-All Email

I want to create a gallery app which is automatically feed by emails. When you register on the app I will provide an email pseudo#domain.com When you send a picture to this email you will receive a push notification and then fetch the image when the app will be open.
To do so, I think about an smtp server (like https://github.com/docker-mailserver/docker-mailserver) and a spring boot to listen all emails (via imap or pop). When an email is received, I will check the from to find the user concerned, save the image until the user open the app to fetch it.
I saw some lib to have an embedded smtp server in a spring boot app (https://github.com/voodoodyne/subethasmtp). But if I understand well it's only for testing.
I didn't find so much information and use case. So maybe I have a bad approach, and read all email from a domain is not a good practice. Do you have some documentation about this ?

How to make Slack app send a private message via an incoming webhook to someone specific?

I created a Slack app that sends a series of interactive messages to a channel. In my Slack API dashboard, I see that I can create and remove hooks. Right now the hook url that I have set up in my code is the one for the Slackbot channel.
But the problem is that such a message only gets sent to me.
I want to send the Slackbot messages to Alice in situation A, and to Bob in situation B. Not just to myself, the guy who configured the app.
What's the best way to do this?
I would suggest that you should not use hooks for this. A more sane way to do this right would be via chat.postMessage Web API method which is documented here!
This is because hooks are tied to specific conversations and that approach quickly hits a wall on what it can really achieve, especially messaging different people. Once you start using the web API it's pretty simple. Just ask for the scope during app installation (remember to add that scope in your dashboard), subscribe to the event in your API dashboard and then you are good to go.
Everytime you send a message via that method, Slack will send you a payload which you can use for testing and logging etc.
You can see all the different ways to message programmatically inside Slack here.

Duplicate emails being produced only through Outlook via Laravel App

We are using a web application to send out mail. Email is sent and received as expected on a server level and in GMail. However, when messages are pushed to our client's Office365 (Outlook), instead of getting one copy they are getting duplicates.
This is how the app works. You can send emails to a number of people (1,5,20, etc). It's all the same message, subject, etc. It's the same email.
The app sends you a copy. Just one. That's how it is supposed to work. Within their Office365 (Outlook) email account, they get their one copy, and then another copy for each recipient (that's not supposed to happen). So, if you email 5 people, instead of getting one email back, they get 6.
The thing is, this program has run flawlessly for nearly a year. Out of the blue, this glitch started happening.
We have had no code changes, no vendor updates, or anything of the sort on the web application side of things that would trigger since before the time this glitch started happening. When we tested locally, and on the live server, with GMail credentials, the app continues to work as it should.
We are sending out mail via SMTP.
The security protocol is "tls".
https://laravel.com/docs/5.5/mail that describes the core Laravel mail function we are using to send out mail.
The client contacted Microsoft support -- who basically said "I don't know. Not my problem".
I don't know where else to turn, or what other steps to take to debug.

Sending a push event from webrick

How can I send a push event via webrick? At certain timings, I want ruby to fire some events and send it to the browser via webrick. I can embed some JavaScript code on the page in advance.
Particularly, I am trying to implement one of the techniques written under HTTP server push and Pushlet on this wikipedia page.
Sawa.
If you want to send some messages to your clients, try Juggernaut2.
Of course, you'll need to start separate node.js-based server to send notifications, but Juggernaut2 works with RoR really well.
Good luck.

Ruby mail APIs that can send an email to a phone

I am trying to write a program in Ruby that can send a email to a phone. Outside of the program, I am able to do this by sending an email to xxx-xxx-xxxx#vtext.com or any other carrier in my Apple Mail client, and it worked fine; it sends a text message to the targeted phone, but when I tried to use a Ruby API (I forget the name), that used sendmail, to send a message, it would not send the message. Are there any ruby APIs that can send an email to a phone? (Or can someone just list some different Ruby mail APIs that I can try)?
I've used ActionMailer and Pony (http://github.com/benprew/pony) in the past.
it should "just work" assuming your mailing system/settings are setup right.

Resources