Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
Add hidden email_host field on site.
Browse files Browse the repository at this point in the history
Use this in case your email domain is different than your web domain.

To change:

> rails console
> Site.current.update_attribute(:email_host, 'emaildomain.com')
  • Loading branch information
seven1m committed Jul 18, 2014
1 parent 17241e0 commit 6f531e1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def can_share?(person)
end

def full_address
address.to_s.any? ? (address + '@' + Site.current.host) : nil
address.to_s.any? ? (address + '@' + Site.current.email_host) : nil
end

def get_people_attendance_records_for_date(date)
Expand Down
2 changes: 1 addition & 1 deletion app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def reply_instructions(to_person)
msg << "Hit \"Reply\" to send a message to #{self.person.name rescue 'the sender'} only.\n"
if group.can_post? to_person
if group.address.to_s.any?
msg << "Hit \"Reply to All\" to send a message to the group, or send to: #{group.address + '@' + Site.current.host}\n"
msg << "Hit \"Reply to All\" to send a message to the group, or send to: #{group.address + '@' + Site.current.email_host}\n"
msg << "Group page: #{Setting.get(:url, :site)}groups/#{group.id}\n"
else
msg << "To reply: #{reply_url}\n"
Expand Down
4 changes: 2 additions & 2 deletions app/models/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def full_message(to, msg, id_and_code=nil)
'List-Archive' => "<#{Setting.get(:url, :site)}groups/#{msg.group.id}>"
) unless to.new_record? # allows preview to work
if msg.group.address.to_s.any? and msg.group.can_post?(msg.person)
h.update 'CC' => "\"#{msg.group.name}\" <#{msg.group.address + '@' + Site.current.host}>"
h.update 'CC' => "\"#{msg.group.name}\" <#{msg.group.address + '@' + Site.current.email_host}>"
end
end
headers h
Expand Down Expand Up @@ -222,7 +222,7 @@ def receive(email)
sent_to.each do |address|
address, domain = address.strip.downcase.split('@')
next unless address.any? and domain.any?
our_domain = [Site.current.host, Site.current.secondary_host].compact.include?(domain)
our_domain = [Site.current.email_host, Site.current.secondary_host].compact.include?(domain)
if our_domain and group = Group.where(address: address).first and group.can_send?(@person)
message = group_email(group, email, body)
if @message_sent_to_group
Expand Down
6 changes: 5 additions & 1 deletion app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ def multisite_host
end
end

def email_host
self[:email_host].presence || host
end

def noreply_email
"noreply@#{self.host}"
"noreply@#{self.email_host}"
end

def visible_name
Expand Down
2 changes: 1 addition & 1 deletion app/views/groups/_form_features.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.input-group
= form.text_field :address, size: 15, class: 'form-control'
%span.input-group-addon
@#{Site.current.host}
@#{Site.current.email_host}
%span.help-block
= t('groups.edit.address.help')
.form-group
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20140718012829_add_email_host_to_sites.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddEmailHostToSites < ActiveRecord::Migration
def change
change_table :sites do |t|
t.string :email_host
end
end
end

0 comments on commit 6f531e1

Please sign in to comment.