I have, successfully, been using the exception_notification gem for many different apps and it is working fine in terms of my workflow etc. I like the reports, the convenience of getting emails etc. The gem hasn't been updated for 8 years (!) but still works fine with one exception - it bloats the memory for every 500-error. Maybe it is just my implementation of the app but I am quite sure I have done it according to spec (it will be another question in that case).
I have googled but can't find another gem that does the same thing: send me an email when my app crashes with a 500-error. What alternatives are there to the exception_notification gem?
There is already a forked version of this gem Exception notification. Explanation says:
The Exception Notification gem provides a set of notifiers for sending notifications when errors occur in a Rack/Rails application. The built-in notifiers can deliver notifications by email, Campfire, HipChat, Slack, Mattermost, IRC or via custom WebHooks.
So this is more enhanced version which can be used with multiple 3rd party applications. The link mentioned in github explain clearly the steps to start using this gem: Read me for Exception Notification
The mailing options and code is pretty much same:
Rails.application.config.middleware.use ExceptionNotification::Rack,
:email => {
:email_prefix => "[PREFIX] ",
:sender_address => %{"notifier" <notifier#example.com>},
:exception_recipients => %w{exceptions#example.com},
:delivery_method => :smtp,
:smtp_settings => {
:user_name => "bob",
:password => "password",
}
}
Related
I would like to scrap mails from a MailBox, this is the situation:
It's about a Technical support with a Ticket System.
A client make a demand on the contact form on the website,
The ticket have a page with a chat and a task list made by the admin in charge of the ticket, so a link to this page is sent to the client who made the demand,
Then when the Admin answer to the ticket in the chat, a mail is sent to the Client, everything to there is ok, the problem is that when the client answer to this email, the content of the mail must be scrapped and added to the database to be seen in the Ticket Chat.
So the Idea is that the Client Can follow the progress of his Ticket by mail instead of going to the ticket page.
I've tried MailMan, but that didn't work, the deamon was starting and then crashed after a couple of minutes whitout scrapping anything, I don't use SendGrid but a private SMTP server so I can't use the Grabber gem of this service.
I'm running Rails 5, my DB is in PostGre, and I'm using ActionMailer as mailing system.
I'm running out of ideas about how to make this feature..
I hope my question is clear enough and my English not too bad.
I suggest you to make an email(any popular provider except gmail) box and configure it to use the pop server. To read it from box use the mail gem.
Mail.defaults do
retriever_method :pop3, :address => "pop.supermail.com",
:port => 995,
:user_name => '<username>',
:password => '<password>',
:enable_ssl => true
end
Then make a daemon to read all income emails and save it to the database, mail gem is just a wrapper around Net::POP3 ruby library and it is super useful for read\receive\parse\build mails.
The ActionMailer here is not a helper for you, it is very handy only for send mails and it does nothing to recieve mail.
I've read the documentation for both services but I just am not seeing the benefits of using Mandrill as opposed to Rail's ActionMailer for transactional services. I can already customize emails with ActionMailer and send them out. Is the difference between the services a matter of volume? If so, at what point would I need to switch out ActionMailer for Mandrill?
This tutorial here is a little bit more confusing because it integrates ActionMailer with Mandrill. MailChimp/Mandrill tutorial
Can someone help me explain the difference? For my real life purpose, all I want to do is send emails to people to reverify their accounts and according to my research that would seem like a job suited for MailChimp.
Basically mailchimp/mandrill is a Saas offering they offer you a SMTP services like the amazon SES service.
ActionMailer is a part of Rails that allow interfacing with a mailing system.
from its docs you can see the following options:
Defines a delivery method. Possible values are:
:smtp (default), can be configured by using config.action_mailer.smtp_settings.
:sendmail, can be configured by using config.action_mailer.sendmail_settings.
:file: save emails to files; can be configured by using config.action_mailer.file_settings.
:test: save emails to ActionMailer::Base.deliveries array.
where the default for SMTP is using localhost (assuming your own server run a SMTP server.
In your case you should use mailchimp to deliver you message, but you will still need to use actionMailer to create the message/email itself.
It reduces complexity by allowing you to offload the sending part.
For the use that you're describing, it sounds like action mailer is just fine.
However, if
You're not interested in managing a mail server
Don't want to spend time trying to figure out if an email was actually sent (based on a client reports)
Want to impose mail quotas easily per client
Then I would recommend mandrill. We've started using it for mailing and haven't looked back since. You get reliability, expert advice / mail system setup and ultimately the biggest feature for me: delivery reporting.
Mandrill allows you to interact with their system via REST API or SMTP. If you're using their SMTP, you would still need to use ActionMailer to deliver email. All you need to do is setup your production.rb file to point to Mandrill:
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 25, # ports 587 and 2525 are also supported with STARTTLS
:enable_starttls_auto => true, # detects and uses STARTTLS
:user_name => "username",
:password => "password", # SMTP password is any valid API key
:authentication => 'login', # Mandrill supports 'plain' or 'login'
:domain => 'example.com', # your domain to identify your server when connecting
}
So to summarize; in my opinion it's not a matter of volume, rather convenience.
I hope that helps.
I use ActiveMailer with a 3rd party mailing provider. To develop my app, I want to actually see the emails that come in, as a user would, in my email client.
So in development mode, instead of disabling email, I want my app to send the mails, but change the "to" field so that every email is sent to me. Is that possible?
Update: I want to test the full route my email takes: going through my ESP, arriving in my inbox, viewing it in gmail. I'm not looking to just test that an email is created.
I personally recommend letter_opener by Ryan Bates, however, if you actually want to deliver the mail instead of just viewing it in the browser, there are a number of plugins available that others have already listed. No one, however, has mentioned that you can very easily accomplish this using Interceptors.
Create a new initializer in your config/initializers directory in your Rails app:
# config/initializers/development_mail_interceptor.rb
class DevelopmentMailInterceptor
def self.delivering_email(message)
message.subject = "[#{message.to}] #{message.subject}"
message.to = "YOUR_EMAIL#gmail.com"
end
end
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
This leverages the power of an interceptor on your app. It doesn't configure anything, but rather changes the envelope on the message, altering the to and subject fields. Replace YOUR_EMAIL with the correct value.
The self.delivering_email(message) method is invoked by ActionMailer. You are hooking into that method and override the message envelope.
Finally, you register that interceptor iff we are currently in the development environment.
Be sure to restart your server, and all your mail (in Development) will actually be sent to your email.
Save yourself some trouble and run MailCatcher. MailCatcher is a simple SMTP server that just grabs outbound email and gives it to you in a simple web interface. Install MailCatcher, add this to your environments/development.rb:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :host => 'localhost', :port => 1025 }
Start MailCatcher when you start your Rails server (or use Foreman or something similar to deal with it), and then go to http://localhost:1080/ to see the email that your application is sending out.
You may consider checking out something like MockSMTP (OS X); instead of modifying your "to" fields, you instead set the mail server for dev mode to the "fake" SMTP server created by the app, and from then on ALL emails (sent to anyone) go instead to the app.
I've never used it myself, but I remember seeing that the devs at 37signals use it.
On other operating systems, you may consider one of the following projects:
letter_opener by Ryan Bates - popup a new browser window when an email is sent
MailCatcher (mentioned by mu is too short) - runs a fake SMTP server and a web-based interface for viewing mail sent to it
mailtrap - similar to MockSMTP, has both a mock SMTP server and also a separate viewer program
As much as I like this answer, I went with a different option.
Use the mail_safe gem! As well as providing the functionality from sethvargo's answer, it doesn't require any work other than adding the gem, and it automatically figures out who to email from their .gitconfig.
One important note that I rarely saw mentioned when researching this is that you must use deliver, not deliver!. The latter doesnt call interceptors (though apparently it still calls observers, if that's helpful).
What are the links/keys needed to create a ruby application to send an SMS using an API. Without having to write gems for it? I have a link to the service and an API key. I need to know where to start. Im new to ruby and am trying to follow this tutorial but cant seem to get anywhere without knowing what i do without using clickatell. http://lukeredpath.co.uk/blog/sending-sms-messages-from-your-rails-application.html
For sending the actual HTTP request, you can use one of the several ruby HTTP libraries/gems, like REST Client, httparty or plain Net/HTTP.
The most simple one might be REST Client, example:
require 'rest_client'
API_URL = 'http://yourapiurl.com/resource'
API_KEY = 'thatoneapikey'
RestClient.post API_URL, :api_key => API_KEY, :number => '7812637813', :body => 'Foo SMS Text Bar Baz'
Best regards
Tobias
There is a gem done by a friend for the routo messaging system
https://github.com/weboglobin/Routo
you can use it, or just take it as an inspiration
Scenario:
I'm a registered user of a site(a rails app).
I have my contacts in linked in whom I would like to invite to see this app(it would be followed up with their registration into this app).
For this , I would be sending them a message with a subject and body.
Rays of Hope:
I need to make use of the messaging api of linkedin and make it talk with my rails app. I can't use the connections api of linked in to retrieve the email addresses as basically any of the linkedin api's don't expose my(the registered user of linked in) contacts email.
To talk with the connections api in my rails app, I was making use of the linkedin gem. It doesn't look like this gem as of now has support for the messaging api of linkedin.
Finally:
Any ideas where can I get started on this..?. I'm kinda clueless as I have never played around with api's directly, ..yet..:).
I'm on Ubuntu 10.04 OS.
Thank you
I had the same problem with the gem lacking messaging functionality. By using the existing code as a reference, I threw this code in an initializer file (config/initializer) and it worked. Give it a try.
LinkedIn::Client.class_eval do
# options should be a hash like this:
# options = {:recipients => {:values => [:person => {:_path => "/people/~" }, :person => {:_path => "/people/USER_ID"} ]}, :subject => "Something",:body => "To read" }
def send_message(options)
path = "/people/~/mailbox"
post(path, options.to_json, "Content-Type" => "application/json")
end
end
This might not exactly answer the question, but could be of some help..
Have you looked here:
https://github.com/pengwynn/linkedin/blob/master/lib/linked_in/api/update_methods.rb
If you'll log an issue on the project repo and include some code, the
whole community can try to help:
https://github.com/pengwynn/linkedin/issues
This was provided by Wynn Netherland on contacting him. Credit goes to him..:)