tricycle / radiant-mailer-extension forked from radiant/radiant-mailer-extension

An extension for Radiant CMS that allows you to create 'contact us' and other mail-bound forms.

This URL has Read+Write access

Glenn Murray (author)
Mon Aug 03 22:38:16 -0700 2009
commit  95eeebeb7ef11b7cdb5be049e9a26d1558f95541
tree    afa3357afb806daa4f112d2b9afe73e5a0dde00b
parent  66900b1b9e8912c3cf740166a32cb595f1a03eeb
radiant-mailer-extension / README
100644 133 lines (111 sloc) 4.944 kb
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
= Mailer Extension for Radiant
 
WARNING TO DEVELOPERS:
This code forked from github.com/radiant/radiant-mailer-extension before a
major refactoring of that code. Contributions to this code are extremely
unlikely to be pulled into the main repo. Your coding efforts would probably be
better spent on extending and improving the main repo (or porting our feature
extensions to the main repo).
 
WARNING TO USERS:
This code is in production for us on several sites, but is not as well
supported as the code at github.com/radiant/radiant-mailer-extension (though as
at 2009-02-02 ours has some extra features). If you don't need something we
have that they don't, you should probably use their code.
 
Created by: M@ McCray - mattmccray.com
   Version: 0.2.1
   Contact: mmccray@elucidata.net
 
Ported to 'mental' by: Sean Cribbs - seancribbs.com
  Version: 0.1
  Contact: seancribbs@gmail.com
 
File upload facility and submit placeholder
  by: Tobin Richard, Tricycle Developments - tricycledevelopments.com
    Version: 0.2
    Contact: tobin.richard@gmail.com
 
The Mailer extension enables form mail on a page. You can define email
templates using pages parts (email, and/or email_html). You configure
the recipients and other Mailer settings in a config part. Following
is an example of a properly formed config part that defines a 'contact'
mailer:
 
mailers:
  contact:
    subject: From the website of Whatever
    from: noreply@mydomain.com
    redirect_to: /contact/thank-you
    recipients:
      - one@one.com
      - two@two.com
      
Required fields:
 
You can specify fields which must be populated or the form will be
invalid and will redisplay the page with an error informing the user
to populate those fields. You can also specify fields which must be
validated 'as_email' (i.e. a@b.com). These settings are put in the
config part. eg:
 
mailers:
  contact:
    [...]
    required_fields:
      - email: as_email
      - firstname
      - surname
 
The following tags are available to help you build the form:
    <r:mailer:form name=""> ... </r:mailer:form>
    <r:mailer:text name="" />
    <r:mailer:password name="" />
    <r:mailer:file name="" />
    <r:mailer:checkbox name="" />
    <r:mailer:radio name="" />
    <r:mailer:radiogroup name=""> ... </r:mailer:radiogroup>
    <r:mailer:select name=""> ... </r:mailer:select>
    <r:mailer:textarea name=""> ... </r:mailer:textarea>
    <r:mailer:option name="" />
    <r:mailer:submit />
    <r:mailer:reset />
    <r:mailer:submit_placeholder />
 
... and the following to help you build the email or email_html templates.
    <r:mailer:get name="" />
 
Simple example of a form:
 
<r:mailer:form name="contact">
 <r:mailer:hidden name="subject" value="Email from my Radiant site!" /> <br/>
  Name:<br/>
 <r:mailer:text name="name" /> <br/>
  Message:<br/>
 <r:mailer:textarea name="message" /> <br/>
 <r:mailer:submit value="Send" />
</r:mailer:form>
 
Forms with file attachments:
 
In many cases it is desirable to limit the maximum size of a file that may be uploaded.
This is set as the max_filesize attribute for mailers in the config page part. Any file
included in the form will have the limit imposed. Following is a simple example config
part that includes a file size limit of 100,000 bytes:
    mailers:
      contact:
        subject: From the website of Whatever
        from: noreply@mydomain.com
        redirect_to: /contact/thank-you
        max_filesize: 100000
        recipients:
          - one@one.com
          - two@two.com
 
The following is a simple form that might be used to submit a file for the above
configuration:
    <r:mailer:form name="contact">
        Type your message: <r:mailer:text name="themessage" /> <br/>
        Select a file: <r:mailer:file name="thefile" /> <br/>
        <r:mailer:submit value="submit"/>
    </r:mailer:form>
 
If a user does not select a file the other form contents will still be e-mailed.
The <r:mailer:get name="foo" /> (with <r:mailer:file name="foo" />) will provide the
uploaded file name.
 
If you are using email or email_html parts then the <r:mailer:get name="" /> tag can be
used to retrieve the name of the uploaded file. If no file was uploaded "" will be
returned.
 
If you wish to show show that activity is taking place during submission you may use
the <r:mailer:submit_placeholder /> tag in your form. This will insert a hidden div with
the contents of the submit_placeholder page part. The div will be displayed when the
user clicks any submit button.
 
Todo:
 * Abstract tag naming, doesn't need to mimick HTML input types
 * Validate recipient emails addresses -- at least the format
 * Better Error handling
 * Status indicator during file uploads
 * Check _all_ file attachment sizes before displaying any file size errors rather
   than stopping at the first.