· 7 years ago · Nov 19, 2018, 03:10 PM
1WORKERS=Processor rake sneakers:run
2
3require 'sneakers'
4require 'json'
5require 'action_mailer'
6
7class Processor
8 include Sneakers::Worker
9 from_queue :email_queue,
10 :env => 'development',
11 :ack => true
12 Sneakers.configure {}
13 Sneakers.logger.level = Logger::ERROR
14
15 Sneakers::Worker.configure_logger(Logger.new('/dev/null'))
16
17 def work(msg)
18 string = msg.force_encoding("ISO-8859-1")
19 hash = JSON.parse(string)
20 ack!
21 UserMailer.test_email(hash).deliver
22 end
23end
24
25require 'action_mailer'
26require 'fog'
27require 'rubygems'
28
29class UserMailer < ActionMailer::Base
30 def test_email(hash)
31 @order = hash["order"]
32 @currentUser = hash["user"]
33 @staffCompany = hash["company"]
34 mail(to: "some.email@gmail.com", from: "another.email@gmail.com", subject: 'Action Mailer')
35 end
36end
37
38<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39<html>
40 <head>
41 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
42 </head>
43 <body>
44 <div class="PlainText">
45 Some text goes here
46 </div>
47 </body>
48</html>
49
50config.action_mailer.perform_deliveries = true
51config.action_mailer.raise_delivery_errors = true
52config.action_mailer.delivery_method = :smtp
53config.action_mailer.smtp_settings = {
54 address: 'smtp.gmail.com',
55 port: 587,
56 domain: 'gmail.com',
57 user_name: 'gmail account',
58 password: 'password',
59 authentication: 'plain',
60 enable_starttls_auto: true}
61
62def work(msg)
63 string = msg.force_encoding("ISO-8859-1")
64 hash = JSON.parse(string)
65 ack!
66 UserMailer.test_email(hash).deliver
67 end
68
69def work(msg)
70 string = msg.force_encoding("ISO-8859-1")
71 hash = JSON.parse(string)
72 UserMailer.test_email(hash).deliver
73 ack!
74 end