groovycrafter-cms

How do I allow a user to send me a email in crafter 3.0?


I am new with crafter 3.0 and right now I am creating a blueprint, one of the sections in my template is the well known "Contact" page where the user writes a message and send it to the site's administrator, I have made all the models,templates and the page is working, but I do not know how to implement the 'send message' feature, is there any control to do that or should I need to create the respective controller?


Solution

  • You could use this helper class (scripts/classes/commons/service) https://gist.github.com/cortiz/234bcdca1d7f24b3c3fce0c3703f1b45#file-emailservice-groovy and then use https://gist.github.com/cortiz/234bcdca1d7f24b3c3fce0c3703f1b45#file-contact-us-groovy in the controller of the page

    Since its a new class you might need to rebuild the context using this: http://docs.craftercms.org/en/3.0/developers/projects/engine/api/site/context/rebuild.html