configuring rails to send email via the microsoft live smtp server - ruby-on-rails

There is a lot of information in rails about setting up rails to work with gmail and I have done this for a personal (e.g. myemail#gmail.com ) website.
Now unfortunately google apps for businesses no longer offers free mail hosting but as it says here apparently outlook do.
so I followed the instructions, changed my DNS MX records and everything and set up smtp (similar to the google version like so )
this gives me (eg from here):
config.action_mailer.deconfig.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.live.com",
:port => 587,
:domain => 'mydomain.com'
:user_name => 'username',
:password => 'mypass',
:authentication => 'plain',
:enable_starttls_auto => true }
ahh. I have finally solved this, I figure I'll post it to save somebody else the hassle. I had massive headaches trying to get this microsoft server to send from any address, my solution is now to use mandrill it's easy to configure and free for less than 12k emails per month.
(DISCLAIMER: I have no connection to Mandrill, please let me know any tips to allow the microsoft server to work, I couldn't and half a day was enough for me)

I have basically identical settings as you but mine is working. I'm guessing your user_name is wrong, it should be
:user_name => "username#mydomain.com"
and also make sure you've at least logged in once to your newly created account to activate it

Related

Alternative to deprecated exception_notification gem in Rails?

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",
}
}

Do i need to use a mail helper class to setup a sendgrid gem? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have created a contact us form in my ruby on rails website. The final stage is to allow messages posted on the form to be forwarded to my email address. For this I have installed the sendgrid gem. However there is one final step and I am stuck. I am following the ruby instructions here
[enter link description here][1]https://devcenter.heroku.com/articles/sendgrid#ruby
To understand what to do i need to know 2 things:
Do I use the code for with mail helper or without mail helper (I don't know what a mail helper is)?
where do I put this code in my rails app?
Any other information about installing sendgrid would be much appreciated.
I recently just set up a contact section on my website using Sendgrid. It works like a charm and I didn't need to install any gems. Here are the steps to take to get your mailer working in production, assuming you already set it up correctly and tested it in your development environment.
First if you haven't already, you need to add a credit card to your Heroku account. This is just for verification and so that you can use add-ons.
In your terminal run:
$ heroku addons:create sendgrid:starter
Fix the ActionMailer settings to work with Sendgrid by adding this to your production rb file:
Rails.application.configure do
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
# more code here
end
You don't need to worry about ENV variables because Heroku automatically adds those from the heroku addons:create command from earlier.

Receive Mails with Rails

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.

Why would I use Mandrill as opposed to the built in ActionMailer?

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.

A way to talk to messaging api of linkedin through rails

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..:)

Resources