| Module | Login::MailConfig |
| In: |
lib/login/mail_config.rb
|
The purpose of this module is to provide an application some control over how the messages are sent without having to overwrite blocks of code. We do this through simple constants. The two constants currently are:
| SUBJECT_PREFIX: | Text that is before every message subject. By default this is not used. You may want to put something like the website here. |
| NOTIFICATIONS_FROM: | Who the message appears to be coming from. By default this is postmaster@yourdomain.com |
If you want to access these same values in your own mailers just mix them into your mailers and the methods will be available.
Will return subject prefix
# File lib/login/mail_config.rb, line 21
21: def subject_prefix
22: return "[#{SUBJECT_PREFIX}] " if
23: Object.const_defined?('SUBJECT_PREFIX')
24: ''
25: end
Email message appear to come from. The constant takes priority but if no constant is defined then the email is extracted from the given param which can be any link that you want the email to appear to come from.
# File lib/login/mail_config.rb, line 31
31: def system_email(extract_from)
32: return NOTIFICATIONS_FROM if
33: Object.const_defined?('NOTIFICATIONS_FROM')
34: host = URI.parse(extract_from).host
35: host = host.split '.'
36: host.shift if host.first =~ /www/i
37: "postmaster@#{host * '.'}"
38: end