user_mailer.rb
2.25 KB
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
58
59
60
61
62
63
64
65
66
class UserMailer < ActionMailer::Base
def activation_email_notify(user)
user_email = "#{user.login}@#{user.email_domain}"
@name = user.name
@email = user_email
@webmail = MailConf.webmail_url(user.login, user.email_domain)
@environment = user.environment.name
@url = url_for(:host => user.environment.default_hostname, :controller => 'home')
mail(
to: user_email,
from: "#{user.environment.name} <#{user.environment.contact_email}>",
subject: _("[%{environment}] Welcome to %{environment} mail!") % { :environment => user.environment.name }
)
end
def activation_code(user)
@recipient = user.name
@activation_code = user.activation_code
@environment = user.environment.name
@url = user.environment.top_url
@redirection = (true if user.return_to)
@join = (user.community_to_join if user.community_to_join)
mail(
from: "#{user.environment.name} <#{user.environment.contact_email}>",
to: user.email,
subject: _("[%s] Activate your account") % [user.environment.name],
)
end
def signup_welcome_email(user)
@body = user.environment.signup_welcome_text_body.gsub('{user_name}', user.name)
email_subject = user.environment.signup_welcome_text_subject
mail(
content_type: 'text/html',
to: user.email,
from: "#{user.environment.name} <#{user.environment.contact_email}>",
subject: email_subject.blank? ? _("Welcome to environment %s") % [user.environment.name] : email_subject,
body: @body
)
end
def profiles_suggestions_email(user)
@recipient = user.name
@environment = user.environment.name
@url = user.environment.top_url
@people_suggestions_url = user.people_suggestions_url
@people_suggestions = user.suggested_people.sample(3)
@communities_suggestions_url = user.communities_suggestions_url
@communities_suggestions = user.suggested_communities.sample(3)
mail(
content_type: 'text/html',
to: user.email,
from: "#{user.environment.name} <#{user.environment.contact_email}>",
subject: _("[%s] What about grow up your network?") % user.environment.name
)
end
class Job < Struct.new(:user, :method)
def perform
UserMailer.send(method, user).deliver
end
end
end