foodsoft/app/models/mailer.rb

42 lines
2.2 KiB
Ruby
Raw Normal View History

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
subject "[#{APP_CONFIG[:name]}] Neues Passwort für/ New password for " + user.nick
2009-01-06 11:49:19 +01:00
recipients user.email
from "FoodSoft <#{APP_CONFIG[:email_sender]}>"
2009-01-06 11:49:19 +01:00
body :user => user,
: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
subject "[#{APP_CONFIG[:name]}] " + message.subject
2009-01-06 11:49:19 +01:00
recipients message.recipient.email
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,
: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
subject "Einladung in die Foodcoop #{APP_CONFIG[:name]} - Invitation to the Foodcoop"
2009-01-06 11:49:19 +01:00
recipients invite.email
from "FoodSoft <#{APP_CONFIG[:email_sender]}>"
2009-01-06 11:49:19 +01:00
body :invite => invite,
: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