2009-01-06 11:49:19 +01:00
|
|
|
# ActionMailer class that handles all emails for the FoodSoft.
|
|
|
|
class Mailer < ActionMailer::Base
|
|
|
|
|
|
|
|
# Sends an email with instructions on how to reset the password.
|
|
|
|
# Assumes user.setResetPasswordToken has been successfully called already.
|
|
|
|
def password(user)
|
|
|
|
request = ApplicationController.current.request
|
2009-01-06 15:45:19 +01:00
|
|
|
subject "[#{APP_CONFIG[:name]}] Neues Passwort für/ New password for " + user.nick
|
2009-01-06 11:49:19 +01:00
|
|
|
recipients user.email
|
2009-01-06 15:45:19 +01:00
|
|
|
from "FoodSoft <#{APP_CONFIG[:email_sender]}>"
|
2009-01-06 11:49:19 +01:00
|
|
|
body :user => user,
|
2009-01-06 15:45:19 +01:00
|
|
|
:link => url_for(:host => request.host, :controller => "login", :action => "password", :id => user.id, :token => user.reset_password_token),
|
|
|
|
:foodsoftUrl => url_for(:host => request.host, :controller => "index")
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# Sends an email copy of the given internal foodsoft message.
|
|
|
|
def message(message)
|
|
|
|
request = ApplicationController.current.request
|
2009-01-06 15:45:19 +01:00
|
|
|
subject "[#{APP_CONFIG[:name]}] " + message.subject
|
2009-01-06 11:49:19 +01:00
|
|
|
recipients message.recipient.email
|
2009-01-06 15:45:19 +01:00
|
|
|
from (message.system_message? ? "FoodSoft <#{APP_CONFIG[:email_sender]}>" : "#{message.sender.nick} <#{message.sender.email}>")
|
2009-01-06 11:49:19 +01:00
|
|
|
body :body => message.body, :sender => (message.system_message? ? 'Foodsoft' : message.sender.nick),
|
|
|
|
:recipients => message.recipients,
|
2009-01-16 02:17:49 +01:00
|
|
|
:reply => url_for(:host => request.host, :controller => "messages", :action => "reply", :id => message),
|
|
|
|
:profile => url_for(:host => request.host, :controller => "home", :action => "profile"),
|
|
|
|
:link => url_for(:host => request.host, :controller => "messages", :action => "show", :id => message),
|
|
|
|
:foodsoftUrl => url_for(:host => request.host, :controller => "/")
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# Sends an invite email.
|
|
|
|
def invite(invite)
|
|
|
|
request = ApplicationController.current.request
|
2009-01-06 15:45:19 +01:00
|
|
|
subject "Einladung in die Foodcoop #{APP_CONFIG[:name]} - Invitation to the Foodcoop"
|
2009-01-06 11:49:19 +01:00
|
|
|
recipients invite.email
|
2009-01-06 15:45:19 +01:00
|
|
|
from "FoodSoft <#{APP_CONFIG[:email_sender]}>"
|
2009-01-06 11:49:19 +01:00
|
|
|
body :invite => invite,
|
2009-01-06 15:45:19 +01:00
|
|
|
:link => url_for(:host => request.host, :controller => "login", :action => "invite", :id => invite.token),
|
|
|
|
:foodsoftUrl => url_for(:host => request.host, :controller => "index")
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|