Skip to content

Commit

Permalink
Fix mailers - provide from address
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanM committed Nov 3, 2016
1 parent d890770 commit 32d2adc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/mailers/spree/base_mailer_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
layout 'mailer'

protected

def from_address
Spree::MailMethod.current.andand.preferred_mails_from ||
'[email protected]'
end


def roadie_options
# This lets us specify assets using relative paths in email templates
super.merge(url_options: {host: URI(spree.root_url).host })
Expand Down
11 changes: 11 additions & 0 deletions app/mailers/spree/order_mailer_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
helper CheckoutHelper
helper SpreeCurrencyHelper

def cancel_email(order, resend = false)
@order = find_order(order)
subject = (resend ? "[#{t(:resend).upcase}] " : '')
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.cancel_email.subject')} ##{order.number}"
mail(to: order.email, from: from_address, subject: subject)
end

def confirm_email_for_customer(order, resend = false)
find_order(order) # Finds an order instance from an id
subject = (resend ? "[#{t(:resend).upcase}] " : '')
Expand Down Expand Up @@ -31,4 +38,8 @@ def invoice_email(order, pdf)
:subject => subject,
:reply_to => @order.distributor.email)
end

def find_order(order)
order.respond_to?(:id) ? order : Spree::Order.find(order)
end
end

0 comments on commit 32d2adc

Please sign in to comment.