Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'mail'
- require 'net/http'
- require 'json'
- begin
- message = $stdin.read
- mail = Mail.new(message)
- uri = URI('https://simplmerchapp.com/admin/tracking_number_email')
- http = Net::HTTP.new(uri.host, uri.port)
- req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
- # raise error if not from Mike/Rishi?
- req.body = {message: mail.body}.to_json
- http.use_ssl = true
- res = http.request(req)
- #raise 'got here'
- #puts "response #{res.body}"
- rescue Exception => e
- Mail.defaults do
- delivery_method :smtp, :address => "smtp.sendgrid.net",
- :port => 587,
- :user_name => 'apikey',
- :password => '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',
- :enable_ssl => true
- end
- message = $stdin.read
- mail = Mail.new(message)
- mail.from = "tracking@simplmerchapp.com"
- mail.to = 'barrett@simpllabs.com'
- mail.subject = 'Simpl Merch: Error Sending Tracking Number HTTP Post'
- mail.body = "#{mail.body}\nError: #{e.message}\nBacktrace: #{e.backtrace}"
- mail.deliver!
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement