java - Mail form in Play Framework 2.0.X -
i'm using play framework (2.0.4) , wonder best way create page form sending email. know there plugin sending email, isn't problem - can write controller method sends email.
my question more action should provide (in routes file). should create post action takes arguments (sender name, sender email, subject, body)? or should somehow create model object filled in form , pass action in controller? best practice? , how glue (how should action in routes file, how should view like)?
you need 2 views - 1 form (let's call mailform
), second - body (bodyhtml
) of mail. (optionally can create bodytxt
if want send html , txt version.
dedicated model helper, use play's form<t>
, if required able store sent messages in db. anyway can operate on map of strings - if plan make many dynamic forms (with unknown number of fields).
after filling form go example sendemail()
action, need fill form (bindfromrequest
) create object , save db , pass bodyhtml view argument. of course instead of returning rendered view action's result should use tostring - send mailer. action should return redirect 'thank you' page. , that's all.
note: written fast, if unclear, let me know ...
Comments
Post a Comment