-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_mailgun.rb
57 lines (49 loc) · 1.68 KB
/
user_mailgun.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module UserMailgun
extend ActiveSupport::Concern
require 'mailgun'
def send_user_activation_mail(user, tag = 'Donkey')
@mail_client = Mailgun::Client.new(ENV['MAILGUN_KEY']) #unless @mail_client.present?
email = user.email
donkey = user_activation_html(user)
donkey = donkey.gsub("\n", "")
#debugger
message_params = {
from: "[email protected]",
to: email,
subject: 'Account Activation | Winery Sales Improvment Project',
html: donkey,
"o:tag" => tag
# "o:testmode" => 'true'
}
response = @mail_client.send_message('communitybenchmark.org', message_params)
rescue Mailgun::CommunicationError => error
return '500'
end
# render_to_string(:action => "users/profile", :layout => false)
def user_activation_html(user)
render_to_string partial: 'user_email/account_activation', locals: {user: user}
end
def send_password_reset_mail(user, tag = 'Donkey')
@mail_client = Mailgun::Client.new(ENV['MAILGUN_KEY']) #unless @mail_client.present?
email = user.email
#inlined = premailer.to_inline_css
#texted = premailer.to_plain_text
mail = password_reset_html(user)
mail = mail.gsub("\n", "")
#debugger
message_params = {
from: "[email protected]",
to: email,
subject: 'Reset Password | Winery Sales Improvment Project',
html: mail,
"o:tag" => tag
# "o:testmode" => 'true'
}
response = @mail_client.send_message('communitybenchmark.org', message_params)
#rescue Mailgun::CommunicationError => error
# return '500'
end
def password_reset_html(user)
render_to_string partial: 'user_email/password_reset', locals: {user: user}
end
end