controller

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 def contact
    @contact = Contact.new
  end

  def create
   @contact = Contact.new(params[:contact])
   if @contact.save and request.post?
     Notifier.deliver_contact(@contact.name, @contact.address, @contact.city, @contact.email, @contact.telephone, @contact.subject, @contact.message, @contact.language, @contact.ip)
     redirect_to contact_sites_path
   else
     render :action => :contact
   end 
  end

SiteMailer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def contact(name, address, city, email, telephone, subj, message, language, ip)
     @from         = "[email protected]"
     @recipients   = "[email protected]"
     headers         "Reply-to" => "#{email}"
     @subject      = "Reactie verzonden via de website"
     @sent_on      = Time.now
     @content_type = "text/html"

     body[:name] = name
     body[:address] = address
     body[:city] = city
     body[:email] = email
     body[:telephone] = telephone
     body[:subj] = subj
     body[:message] = message
     body[:language] = language
     body[:ip] = ip
  end

template

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contactmail Website</title>
</head>

<body>
  <h1>Betreft : <%= @subject %></h1>
  <h3>Verzonden op : <%= Time.now.strftime("%d/%m/%Y om %H:%M") %></h3>

  <p>
    <strong>Naam : </strong> <%= @name %>
  </p>

  <p>
    <strong>Adres : </strong> <%= @address %>
  </p>

  <p>
    <strong>Gemeente : </strong> <%= @city %>
  </p>

  <p>
    <strong>Email : </strong> <%= @email %>
  </p>

  <p>
    <strong>Telefoonnummer : </strong> <%= @telephone %>
  </p>

  <p>
    <strong>Taal : </strong> <%= @language %>
  </p>

  <p>
    <strong>IP : </strong> <%= @ip %>
  </p>

  <p><strong>Bericht :</strong><br />
    <%= @message %>  
  </p>
</body>
</html>