hulaki 0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +0,0 @@
1
- sms:
2
- # The later config will override the former one
3
- gateway:
4
- name: twilio
5
- keys:
6
- TWILIO_ACCOUNT_SID: ACf43b1e6876as8d7a6sd27515ea49e418
7
- TWILIO_AUTH_TOKEN: 75768435c30daeef519439kjhkjahsdk
8
- TWILIO_PHONE_NUMBER: "+150447566666"
9
-
10
- gateway:
11
- name: twilio
12
- keys:
13
- TWILIO_ACCOUNT_SID: ACf43b1e6167987123jhkhkhkjjj49e418
14
- TWILIO_AUTH_TOKEN: 75768435c30daeef519439c123123123f
15
- TWILIO_PHONE_NUMBER: "+154444451701"
16
-
17
- email:
18
- delivery_method: smtp
19
- address: "smtp.gmail.com"
20
- port: 587
21
- domain: 'gmail.com'
22
- user_name: "jyaasaruby@gmail.com"
23
- password: "p@ssword123"
24
- authentication: "plain"
25
- from: 'shishir'
data/lib/hulaki/mailer.rb DELETED
@@ -1,59 +0,0 @@
1
- class Hulaki::Mailer
2
- def initialize(params={})
3
- configure
4
- @reciever = params[:to]
5
- @sender = @env["from"]
6
- sender_email = @env["user_name"]
7
- @message = params[:body]
8
- @sub = params[:sub]
9
- validate(@reciever, sender_email, @message)
10
- end
11
-
12
- def deliver
13
- @msg.deliver
14
- "sent"
15
- end
16
-
17
- private
18
- def configure
19
- @env = Hulaki::Config.new.parse["email"]
20
- address = @env["address"]
21
- port = @env["port"]
22
- domain=@env["domain"]
23
- user_name = @env["user_name"]
24
- password = @env["password"]
25
- authentication = @env["authentication"]
26
- Mail.defaults do
27
- delivery_method :smtp,
28
- {
29
- :address => address,
30
- :port => port,
31
- :domain => domain,
32
- :user_name => user_name,
33
- :password => password,
34
- :authentication => authentication,
35
- :enable_starttls_auto => true
36
- }
37
- end
38
- end
39
-
40
- def create_mail
41
- @msg = Mail.new({
42
- :to => @reciever,
43
- :from => @sender,
44
- :subject => @sub,
45
- :body => @message
46
- })
47
- self.deliver
48
- end
49
-
50
- def validate(reciever, sender, message)
51
- validator = Hulaki::EmailValidator.new(from: reciever, to: sender, message: message)
52
- errors = validator.validates_format && validator.validates_presence
53
- if (errors.empty?)
54
- create_mail
55
- else
56
- errors
57
- end
58
- end
59
- end