Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Getting a contact form to email properly

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1270 Views
  • Andrew Houle
    Community Member
    132 Posts

    Getting a contact form to email properly Link to this post

    I've been studying how to create a customized contact form using these forum discussions: http://www.silverstripe.com/site-builders-forum/flat/53148 and http://www.silverstripe.com/site-builders-forum/flat/113907?showPost=164944. My simple form works to save the data in a database, but I'm struggling to send the data to the site owner. I'm not sure where to put my template file MyEmail.ss, and what exactly goes in it? And, do I need a MyEmail.php class file that extends Email.php. If so, what goes in that and where would I place that? Here is my code so far:


    class ContactUsPage extends Page {


    class ContactUsPage_Controller extends Page_Controller {

       function ContactUsForm() {
          return new Form($this, "ContactUsForm", new FieldSet(

             // List your fields here
             new TextField("Name", "Name"),
             new EmailField("Email", "Email Address"),
             new TextareaField("Message", "Message")

          ), new FieldSet(

             // List the action buttons here
             new FormAction("SubmitContactUs", "Submit")

          ), new RequiredFields(

             // List the required fields here: "Email", "FirstName"

        function SubmitContactUs( $data, $form ) {
       $submittedForm = new ContactData();
          $email = new MyEmail;





  • Liam
    Community Member
    470 Posts

    Re: Getting a contact form to email properly Link to this post

    The email templates go in mysite/templates/email/MyEmail.ss

    Setup this up as an html document type and loop through the data with something like <% control FormData %>variables here <% end_control %>

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.