daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Dec 8th, 2015 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'net/smtp'
  2.  
  3. class OrdersController < ApplicationController
  4.   def finish
  5.     @order = Order.find(params[:id])
  6.     order_finish_url = url_for :controller => 'orders', :action => 'finish', :id => @order.id, :email => false
  7.  
  8.     if params[:email].nil? || params[:email].empty?
  9.       message = <<EOF
  10. From: Coder Restaurant <your-username@gmail.com>
  11. To: #{@order.customer_name} <#{@order.email}>
  12. Subject: Coder Restaurant - Order succeeded!
  13. Thank you for your order.
  14. You can view your order detail at: #{order_finish_url}
  15. EOF
  16.       #Using Block
  17.       smtp = Net::SMTP.new('smtp.gmail.com', 587 )
  18.       smtp.enable_starttls
  19.         smtp.start('gmail.com', 'your-username@gmail.com', 'your-password', :login) do |smtp|
  20.           smtp.send_message message, 'your-username@gmail.com', @order.email
  21.         end
  22.     end
  23.   end
  24. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top