NAME

GT::Mail::Editor - E-mail template editor


SYNOPSIS

Generally used from templates:

    <%GT::Mail::Editor::tpl_load(
        dir => $template_root,
        template => $template_set,
        file => $filename,
        header => From,
        header => To,
        header => Subject
    )%>
    <%if error%>
        Unable to load e-mail template: <%error%>
    <%else%>
        From: <input type=text name=header_From value="<%header_From%>">
        To: <input type=text name=header_To value="<%header_To%>">
        Subject: <input type=text name=header_Subject value="<%header_Subject%>">
        Other headers:<br>
        <textarea name=extra_headers>
        <%loop extra_headers%><%name%>: <%value%>
        <%endloop%>
    <%endif%>
    - or -
    <%GT::Mail::Editor::save(
        dir => $template_root,
        template => $template_set,
        file => $filename,
        header => To => $header_To,
        header => From => $header_From,
        header => Subject => $header_Subject,
        extra_headers => $extra_headers
    )%>
    <%if error%>Unable to save e-mail template: <%error%>
        ... Display the above form in here ...
    <%endif%>


DESCRIPTION

GT::Mail::Editor is designed to provide a template interface to creating and editing a wide variety of e-mail templates. Although not currently supported, eventually attachments, HTML, etc. will be supported.

tpl_load - Loads a template (from the templates)

Calling GT::Mail::Editor::tpl_load from a template returns variables required to display a form to edit the template passed in.

dir

Defines the base directory of templates.

template

This defines a template set. This is optional. If present, this directory will be tacked onto the end of 'dir'. This is simply to provide a more flexible way to specify the template directory. For example, if you have 'dir' set to '/a/b' and template set to 'c', then the directory '/a/b/c' will be used to save and load e-mail templates.

file

Specify the filename of the template inside the directory already specified with 'dir' and 'template'

header

Multiple ``special'' headers can be requested with this. The argument following each 'header' should be the name of a header, such as ``To''. Then, in the variables returned from tpl_load(), you will have a variable such as 'header_To' available, containing the value of the To: field.

tpl_save - Save a template

dir template file

See the entries in tpl_load

header

Specifies that the two following arguments are the field and value of a header field. For example, header => To => ``abc@example.com'' would specify that the To field should be ``abc@example.com'' (To: abc@example.com).

extra_headers

The value to extra_headers should be a newline-delimited list of headers other than those specified with header. These will be parsed, and blank lines skipped.

body

The body of the message. Need I say more? MIME messages are possible by inserting them directly into the body, however currently MIME messages cannot be created using this editor.

load

Attempts to load a GT::Mail::Editor object with data passed in. This can take either a file handle or a filename. If passing a filename, dir and template will be used (if available). You should construct an object with new() prior to calling this method.

new

Constructs a new GT::Mail::Editor object. This will be done automatically when using the template methods tpl_load and tpl_save. Takes the following arguments:

dir

Defines the base directory of templates.

template

This defines a template set. This is optional. If present, this directory will be tacked onto the end of 'dir'. This is simply to provide a more flexible way to specify the template directory. For example, if you have 'dir' set to '/a/b' and template set to 'c', then the directory '/a/b/c' will be used to save and load e-mail templates.


COPYRIGHT

Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved. http://www.gossamer-threads.com/


VERSION

Revision: $Id: Editor.pm,v 1.25 2008/09/23 23:55:26 brewt Exp $