Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. require 'rubygems'
  2. require 'mail'
  3. require 'net/http'
  4. require 'json'
  5.  
  6. begin
  7.  
  8.  
  9.         message = $stdin.read
  10.         mail = Mail.new(message)
  11.  
  12.  
  13.         uri = URI('https://simplmerchapp.com/admin/tracking_number_email')
  14.         http = Net::HTTP.new(uri.host, uri.port)
  15.         req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
  16.         # raise error if not from Mike/Rishi?
  17.         req.body = {message: mail.body}.to_json
  18.         http.use_ssl = true
  19.         res = http.request(req)
  20.         #raise 'got here'
  21.         #puts "response #{res.body}"
  22. rescue Exception => e
  23.  
  24. Mail.defaults do
  25. delivery_method :smtp, :address => "smtp.sendgrid.net",
  26. :port => 587,
  27. :user_name => 'apikey',
  28. :password => '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',
  29. :enable_ssl => true
  30.         end
  31.  
  32.  
  33.         message = $stdin.read
  34.         mail = Mail.new(message)
  35.         mail.from = "tracking@simplmerchapp.com"
  36.         mail.to = 'barrett@simpllabs.com'
  37.         mail.subject = 'Simpl Merch: Error Sending Tracking Number HTTP Post'
  38. mail.body = "#{mail.body}\nError: #{e.message}\nBacktrace: #{e.backtrace}"
  39.         mail.deliver!
  40.  
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement