简体   繁体   中英

Ruby on Rails sending emails to users on AD using omniauth-ldap

I'm completely new to Ruby on Rails and I have to build an email system which first uses the company's ID and the omniauth LDAP plugin to login (I already have all the credentials). I also have a project with a form already made. What I'm trying to accomplish is to have an email sent out to specific people once the user logs in and fills out a form . So far all the tutorials I've come across deal only with sending an automatic confirmation email to the user who has created the profile but that's not what I need at all. I have no need for the application to create a new user whatsoever but only wants to send a html/text template I've created to the specified emails. I'm not sure which files code to supply, this is my first time using stackoverflow to ask questions so I apologize in advance for not giving all the correct information. I'm using devise to create the user model. I can supply any files codes necessary and if anyone can point me in the right direction it would be great!

my gemfile looks as such:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'devise'
gem 'omniauth'
gem 'omniauth-ldap', :git => 'https://github.com/intridea/omniauth-ldap.git'




# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read                                                                                     more:            https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin

So which step you are lost at? Here are the things to do with email sending:

  1. Create a controller, an action and a corresponding route responsible for processing the information inputted into a form by a logged in user. At this step you should get all the inputted data inside of your action in params variable.
  2. Create a mailer class (more on this here ) which sends emails to desired receivers using provided html template.
  3. Initiate email delivery from your action created at step 1. You should pass the params obtained from a form to mailer (in case that params should be displayed in a resulting email message).

You should also remember that development environment does not send any emails by default. Their text is displayed in your server console. Have a look at "Action Mailer Configuration" section of the same tutorial to get the idea of doing with it. As an option, you can save email files to your local folder using

:delivery_method => :file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM