Results 1 to 7 of 7

Thread: Mailing in Spring Framework

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    Question Mailing in Spring Framework

    Hello All,
    I am creating a small web app which sends out mail for marketers, so I have created beans the application content, which have different mail factories .For respective mail factory we have templates. Now my requirement is to change the content of the templates dynamically as well as storing that HTML template at a location so that my server can pick it up which I send my for that marketer guy.
    Please let me know if you guys have any thoughts or ideas on this.

  2. #2
    Join Date
    Dec 2008
    Posts
    12

    Default

    Hi jaistage

    Could you elaborate a bit more? I am unable to understand especially the following sentence:

    Quote Originally Posted by jaistage View Post
    storing that HTML template at a location so that my server can pick it up which I send my for that marketer guy.
    Rgds
    guybrush

  3. #3
    Join Date
    Dec 2008
    Posts
    3

    Question Dynamic:Mail

    I mean that my mail templates are stored in a folder in my tomcat, if I change that email template from a JSP page (the contents in the template) how would they be written in that file in the tomcat.
    I want to say that my templates are kept at a location outside my normal WAR, is there a way to update these templates on the server through the web ???

  4. #4
    Join Date
    May 2008
    Location
    Berlin, Germany
    Posts
    36

    Default

    Don't know if this helps:

    We are using freemarker for the view layer and thus for all templates.
    The templates are stored localized in the classpath.

    The template:
    ==========
    Hello ${login}
    We welcome you at ....
    Please click the link below to activate your account
    http://.../user/register/confirmkey?invitationKey=${invkey}

    The model-object:
    // contains the tokens
    Map<String, String> model = new HashMap<String, String>();

    // our model should now about
    model.put(EMAIL_CONTENT_LOGIN, identity.getLogin());
    model.put(EMAIL_CONTENT_INVKEY, identity.getInvitationKey());

    The main code to fetch the replace the tokens in the template looks like:
    msg = FreeMarkerTemplateUtils.processTemplateIntoString( mailTemplateEngine.getTemplate(EMAIL_CONFIRMATION_ TEMPLATE,locale,ENCODING_DEFAULT,true) ,model);

    This way freemarker picks up a template from the classpath, parses it and replaces the tokens by the params

    does this help ???

  5. #5

    Default

    It sounds like the poster wants to give clients the ability to modify the templates on-the-fly via a web interface.

    Certainly a java class can save text to a file anywhere on the file system; it need not be within the web path. So one option is to load up the template contents into a JSP, edit them, and save using a FileWriter or some such. Note that you can't save just the changes -- you have to delete and save the whole thing.

    Another option (the one we have chosen to use) is to put the templates into a database. We're using Velocity and you can use VelocityEngine.evaluate to do the template substitution with any string (such as a template string retrieved from a database). Happy to post code if you need.

  6. #6
    Join Date
    Dec 2008
    Posts
    12

    Default

    Quote Originally Posted by jacobmattison
    Another option (the one we have chosen to use) is to put the templates into a database.
    This sounds reasonable. I think I'd have a funny feeling in my stomach letting the (web-)app write "anywhere" in the filesystem.

    Rgds
    guybrush

  7. #7
    Join Date
    Dec 2008
    Posts
    3

    Default

    Thanks a lot Jacob,
    I am looking into the way you have mentioned will let you know soon.

Tags for this Thread

Posting Permissions

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