Skip to content

Commit

Permalink
Implement ability to customize sender name in emails.
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Feb 20, 2012
1 parent c0fdb95 commit c3d68cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -3,7 +3,7 @@ tmp/**/*
tmp/*.txt
db/*.sqlite3
config/database.yml
.idea
config/config.yml
utils/watchdog/watchdog.log
utils/watchdog/watchdog.pid
utils/hw-daemon/hw-daemon.log
Expand All @@ -12,4 +12,3 @@ utils/hw-daemon/hw-daemon.ini
build/build.log
build/ovz-web-panel-*.tgz
build/ovz-web-panel
*.sw?
14 changes: 11 additions & 3 deletions app/models/user_mailer.rb
Expand Up @@ -3,21 +3,29 @@
class UserMailer < ActionMailer::Base

def restore_password_email(user, link)
recipients user.email
setup_common_fields(user.email)
subject I18n.t('restore_password.mail.restore_link.subject')
body :link => (link + "?user_id=#{user.id}&hash=" + Digest::SHA1.hexdigest(user.crypted_password + user.login))
end

def request_email(user, request)
recipients user.email
setup_common_fields(user.email)
subject I18n.t('admin.requests.mail.new_request.subject', :id => request.id)
body :request => request
end

def request_comment_email(user, comment)
recipients user.email
setup_common_fields(user.email)
subject I18n.t('admin.requests.mail.new_comment.subject', :request_id => comment.request_id)
body :comment => comment
end

private

def setup_common_fields(email)
from_address = AppConfig.email.from
from from_address if from_address
recipients email
end

end
3 changes: 3 additions & 0 deletions config/initializers/app_config.rb
Expand Up @@ -54,6 +54,9 @@
'host' => 'example.com',
'login_pattern' => 'uid=<login>,ou=people,dc=example,dc=com',
},
'email' => {
'from' => '',
},
}

def hashes2ostruct(object)
Expand Down

0 comments on commit c3d68cb

Please sign in to comment.