www.webdeveloper.com
Results 1 to 4 of 4

Thread: OOP Script

  1. #1
    Join Date
    Jan 2004
    Location
    Sarasota, FL
    Posts
    150

    Red face OOP Script

    I have installed an object oriented perl script (TFmail.) The script provides a mechanism to send an auto-response. One is required to set values in a config file for "confirmation_template", "confirmation_subject", "confirmation_email_from".

    The email form report and screen confirmation also have defalult templates which I have successfully altered.

    I have set the three values above and created a welcome.trt template in the configs dir. But I cannot figure out what to put in the templare so that it cooperates with the script to send my text.

    In the script there is sub routine:

    =item send_confirmation_email ( TREQ, CONFTO )

    Sends the confirmation email back to the user if configured
    to do so and we have a reasonable email address for the user.

    The CONFTO parameter must be the sanity checked user's email
    address or the empty string it no valid email address was
    given.

    Dies on error.

    =cut

    sub send_confirmation_email
    {
    my ($treq, $confto) = @_;

    return unless length $confto;

    my $conftemp = $treq->config('confirmation_template', '');
    return unless length $conftemp;

    my $save = clean_template($treq);
    my $body = $treq->process_template($conftemp, 'email', undef);
    restore_template($treq, $save);

    send_email($treq, {
    To => $confto,
    From => $treq->config('confirmation_email_from',POSTMASTER),
    Subject => $treq->config('confirmation_subject', 'Thanks'),
    body => $body,
    });
    }


    It looks like the "body" in the last line is the text of the auto-response and should be found in the template ... but what would be the syntax???? Or maybe I have this whole thing wrong. I can be dense. This is my special phrase " I CAN BE DENSE."
    PghRed

  2. #2
    Join Date
    Feb 2007
    Posts
    4
    Hi,

    Looks to me like you can put anything in the template (text, html, xml, etc.) but I don't know the script so I'm no expert.

    In the config file I'd put something like:
    confirmation_subject="My Subject Line"
    confirmation_email_from="originatehere@mail.com"
    confirmation_template="/mailtemplates/mytemplate.txt"

    In the /mailtemplates/mytemplate.txt file I'd just put something like this
    Line 1 My
    Line 2 basic
    Line 3 text
    Line 4 template
    Line 5
    Line 6 Yours truly
    Line 7 Happy!

    And give it a go to see what happens. If not, try changing the config file not to include the "", change the = to a : etc.

    Good Luck!

  3. #3
    Join Date
    Jan 2004
    Location
    Sarasota, FL
    Posts
    150
    In the config file I'd put something like:
    confirmation_subject="My Subject Line"
    confirmation_email_from="originatehere@mail.com"
    confirmation_template="/mailtemplates/mytemplate.txt"

    The syntax for declaring the config files is:

    confirmation_subject: The Subject
    confirmation_email_from: originatehere@mail.com
    confirmation_template: mytemplate.trt

    This is the exact syntax ... no equals, no quotes, no semicolon.

    The runtime error that I am receiving is for incorrect character in file mytemplate.trt. So everthing else is set up right. In fact, the script runs ... it sends back the form results but then stops at sthe syntax error.

    Here is what the default template looks like for sending back form results:

    %% NMS email template file %%
    Web site information request {= by_submitter =}on {= date =}.
    ----------------------------------------------------------------------

    {= FOREACH input_field =}
    {= name =}: {= value =}

    {= END =}
    ----------------------------------------------------------------------

    Here is the defalult thank you template to the screen:

    %% NMS html template file %%
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Thank You</title>
    <link rel="stylesheet" type="text/css" href="/css/nms.css" />

    <!-- etc... you get the idea -->

    </body>
    </html>

    I know I can put in HTML. And I see the syntax tused to refer to form gathered values. My template should look like this:

    %% NMS email template file %%

    # No heading is needed
    ----------------------------------------------------------------------
    Welcome:

    We are so happy to add your name to the list of teachers, parents and citizens etc ....
    ---------------------------------------------------------------------

    BUT ... I have tried just the text ... no luck. I have tried putting it in quotes ... no luck. Ideally I would just like to put in a reference to a text file since the welcome letter is long. Is your suggestion to actually include the line numbers before the lines of text? Obviously the text of the letter goes in the template since the other templates contain the text that is sent back to me and the screen.

    BUT ... what syntax?

    ----------------------------------------------------------------------
    PghRed

  4. #4
    Join Date
    Jan 2004
    Location
    Sarasota, FL
    Posts
    150
    PS. I have read the documentation carefully and it does give a hint what goes in the confirmation template. I have asked the authors of the script on their support page but I have no hope that they will respond. Anyway ... thanks for thinking about it. I am ready to give up ... but I never give up.
    PghRed

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles