Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/smtp'
- class OrdersController < ApplicationController
- def finish
- @order = Order.find(params[:id])
- order_finish_url = url_for :controller => 'orders', :action => 'finish', :id => @order.id, :email => false
- if params[:email].nil? || params[:email].empty?
- message = <<EOF
- From: Coder Restaurant <your-username@gmail.com>
- To: #{@order.customer_name} <#{@order.email}>
- Subject: Coder Restaurant - Order succeeded!
- Thank you for your order.
- You can view your order detail at: #{order_finish_url}
- EOF
- #Using Block
- smtp = Net::SMTP.new('smtp.gmail.com', 587 )
- smtp.enable_starttls
- smtp.start('gmail.com', 'your-username@gmail.com', 'your-password', :login) do |smtp|
- smtp.send_message message, 'your-username@gmail.com', @order.email
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement