Search

Hello all i’m new to symphony cms and i like it very much its better than many others. But i have a problem with getting my mail form to work i have to use smtp because the mail() function wont work. I just downloaded the SMTP extension. And i enebled it then i made a new page called contact and made a new event with the needed filter. I placed the following code into the xsl page:

<form action="" method="post">
  <fieldset>
    <label>Name <input type="text" name="fields[author]" value="" /></label>
    <label>Email <input type="text" name="fields[email]" value="" /></label>
    <label>Message <textarea name="fields[message]" rows="5" cols="21"></textarea></label>
    <input name="send-email[sender-email]" value="fields[email]" type="hidden" />
    <input name="send-email[sender-name]" value="fields[author]" type="hidden" />    
    <input name="send-email[subject]" value="You are being contacted" type="hidden" />
    <input name="send-email[body]" value="fields[message]" type="hidden" />
    <input name="send-email[recipient]" value="fred" type="hidden" />
    <input id="submit" type="submit" name="action[save-contact-form]" value="Send" />
  </fieldset>
</form>

And it does not work.

Thank you!

Do you get any errors? Does the entry save successfully into your section, but no email is sent?

Try changing your form element to:

<form action="?debug" method="post">

This will post the form and let you see the XML returned from the event. It might give you some more information as to why it is failing.

No errors but how do i configure the smtp settings? Ok i can try that. Thank you.

Sorry just found where to configure the settings.

I’ve filled in the settings but still it issent working. Do i forget something?

I tried

<form action=”?debug” method=”post”

there’s nothing to see.

there’s nothing to see.

Do you see your debug XML or do you see a blank page? If you see a blank white page then this means a server error occurred. Or if you see your debug XML, is it that the <events> element is empty?

The more descriptive you are, the more we can help you.

Here’s the xml content. <?xml version="1.0" encoding="utf-8" ?> <data> <events /> </data>

Did you definitely attach the Event to the page? The form is passing the action save-contact-form to the event, so look in the PHP to check that the condition of the load or __trigger() functions are checking for this in the $_POST array.

Yesterday i was at school so i could go on with the cms.

I attached the event to the page here is the code of the event.php file. I think the problem is somewhere in this file.

require_once(TOOLKIT . ‘/class.event.php’);

Class eventcontact extends Event{

    const ROOTELEMENT = 'contact';

    public $eParamFILTERS = array(
        'smtp-email-library-send-email-filter'
    );

    public static function about(){
        return array(
                 'name' => 'Contact',
                 'author' => array(
                        'name' => 'Sander Groen',
                        'website' => 'http://www.website',
                        'email' => 'mail@website.com'),
                 'version' => '1.0',
                 'release-date' => '2010-03-30T14:55:30+00:00',
                 'trigger-condition' => 'action[save-contact-form]');   
    }

    public static function getSource(){
        return '19';
    }

    public static function allowEditorToParse(){
        return true;
    }

    public static function documentation(){
        return '
    <h3>Success and Failure XML Examples</h3>
    <p>When saved successfully, the following XML will be returned:</p>
    <pre class="XML"><code>&lt;contact result="success" type="create | edit">

<message>Entry [created | edited] successfully.</message> </contact>

When an error occurs during saving, due to either missing or invalid fields, the following XML will be returned:

<contact result="error">
  <message>Entry encountered errors when saving.</message>
  <field-name type="invalid | missing" />
  ...
</contact>

The following is an example of what is returned if any filters fail:

<contact result="error">
  <message>Entry encountered errors when saving.</message>
  <filter name="admin-only" status="failed" />
  <filter name="send-email" status="failed">Recipient username was invalid</filter>
  ...
</contact>

Example Front-end Form Markup

This is an example of the form markup you can use on your frontend:

<form method="post" action="" enctype="multipart/form-data">
  <input name="MAXFILESIZE" type="hidden" value="5242880" />
  <label>Bedrijfsnaam
    <input name="fields[bedrijfsnaam]" type="text" />
  </label>
  <label>Contactpersoon
    <input name="fields[contactpersoon]" type="text" />
  </label>
  <label>Telefoonnummer
    <input name="fields[telefoonnummer]" type="text" />
  </label>
  <label>Emailadres
    <input name="fields[emailadres]" type="text" />
  </label>
  <label>Vraag/Opmerking
    <textarea name="fields[vraag-opmerking]" rows="15" cols="50"></textarea>
  </label>
  <input name="action[contact]" type="submit" value="Submit" />
</form>

To edit an existing entry, include the entry ID value of the entry in the form. This is best as a hidden field like so:

<input name="id" type="hidden" value="23" />

To redirect to a different location upon a successful save, include the redirect location in the form. This is best as a hidden field like so, where the value is the URL to redirect to:

<input name="redirect" type="hidden" value="http://localhost/promoteyourstore/cms/success/" />

Send Email via Direct SMTP Connection

The send email filter, upon the event successfully saving the entry, takes input from the form and send an email to the desired recipient. This filter currently does not work with the “Allow Multiple” option. The following are the recognised fields:

send-email[sender-email] // Optional
send-email[sender-name] // Optional
send-email[subject] // Optional
send-email[body]
send-email[recipient] // comma separated list of author usernames.

All of these fields can be set dynamically using the exact field name of another field in the form as shown below in the example form:

<form action="" method="post">
  <fieldset>
    <label>Name <input type="text" name="fields[author]" value="" /></label>
    <label>Email <input type="text" name="fields[email]" value="" /></label>
    <label>Message <textarea name="fields[message]" rows="5" cols="21"></textarea></label>
    <input name="send-email[sender-email]" value="fields[email]" type="hidden" />
    <input name="send-email[sender-name]" value="fields[author]" type="hidden" />
    <input name="send-email[subject]" value="You are being contacted" type="hidden" />
    <input name="send-email[body]" value="fields[message]" type="hidden" />
    <input name="send-email[recipient]" value="fred" type="hidden" />
    <input id="submit" type="submit" name="action[save-contact-form]" value="Send" />
  </fieldset>
</form>
    public function load(){         
        if(isset($_POST['action[save-contact-form]'])) return $this->__trigger();
    }

    protected function __trigger(){
        include(TOOLKIT . '/events/event.section.php');
        return $result;
    }       

}

I may have no idea, but my understanding about sendmail is that the recipient must be a Symphony Author as the message is sent to the Author’s registered email account. So where you have ‘fred’, do you actually have an author called Fred?

Thanks for your reply brendo. That was the default value of the event.php i’ve tried that but is doesn’t work.

Yes, it won’t work because in Symphony I imagine you don’t have an Author called Fred :)

Try putting your Symphony username in the form (ie. replace Fred) and see if the email that’s attached to your account receives the mail.

I tried but unfortunately it does not work.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details