K
K
Konstantin-P922018-07-07 09:49:36
MODX
Konstantin-P92, 2018-07-07 09:49:36

MODX contact form Formit does not send emails, what to do?

Hello.
For the first time I encountered MODX in a day already 2 problems)) I solved 1 problem thanks to this service.
There was a second problem.
In MODX there is a feedback form, it works through Formit.
The problem is that when we leave any application on the site (Callback, find out the price of a product, etc.)
, these applications do not come to the mail.
I looked at the lessons on setting up Formit, read the instructions on setting up Formit, nothing helps.
Maybe someone can point me to my mistake.
Letters should be sent to the mail: [email protected]
The site was not created by me, I'm just an administrator)) I
also attached the code from the form site:

[




AjaxForm snippet code
<?php
/** @var array $scriptProperties */
/** @var AjaxForm $AjaxForm */
if (!$modx->loadClass('ajaxform', MODX_CORE_PATH . 'components/ajaxform/model/ajaxform/', false, true)) {
    return false;
}
$AjaxForm = new AjaxForm($modx, $scriptProperties);

$snippet = $modx->getOption('snippet', $scriptProperties, 'FormIt', true);
$tpl = $modx->getOption('form', $scriptProperties, 'tpl.AjaxForm.example', true);
$formSelector = $modx->getOption('formSelector', $scriptProperties, 'ajax_form', true);
$objectName = $modx->getOption('objectName', $scriptProperties, 'AjaxForm', true);
$AjaxForm->loadJsCss($objectName);

/** @var pdoTools $pdo */
if (class_exists('pdoTools') && $pdo = $modx->getService('pdoTools')) {
    $content = $pdo->getChunk($tpl, $scriptProperties);
} else {
    $content = $modx->getChunk($tpl, $scriptProperties);
}
if (empty($content)) {
    return $modx->lexicon('af_err_chunk_nf', array('name' => $tpl));
}

// Add selector to tag form
if (preg_match('#<form.*?class=(?:"|\')(.*?)(?:"|\')#i', $content, $matches)) {
    $classes = explode(' ', $matches[1]);
    if (!in_array($formSelector, $classes)) {
        $classes[] = $formSelector;
        $classes = preg_replace(
            '#class=(?:"|\')' . $matches[1] . '(?:"|\')#i',
            'class="' . implode(' ', $classes) . '"',
            $matches[0]
        );
        $content = str_ireplace($matches[0], $classes, $content);
    }
} else {
    $content = str_ireplace('<form', '<form class="' . $formSelector . '"', $content);
}

// Add method = post
if (preg_match('#<form.*?method=(?:"|\')(.*?)(?:"|\')#i', $content)) {
    $content = preg_replace('#<form(.*?)method=(?:"|\')(.*?)(?:"|\')#i', '<form\\1method="post"', $content);
} else {
    $content = str_ireplace('<form', '<form method="post"', $content);
}

// Add action for form processing
$hash = md5(http_build_query($scriptProperties));
$action = '<input type="hidden" name="af_action" value="' . $hash . '" />';
if ((stripos($content, '</form>') !== false)) {
    if (preg_match('#<input.*?name=(?:"|\')af_action(?:"|\').*?>#i', $content, $matches)) {
        $content = str_ireplace($matches[0], '', $content);
    }
    $content = str_ireplace('</form>', "\n\t$action\n</form>", $content);
}

// Save settings to user`s session
$_SESSION['AjaxForm'][$hash] = $scriptProperties;

// Call snippet for preparation of form
$action = !empty($_REQUEST['af_action'])
    ? $_REQUEST['af_action']
    : $hash;

$AjaxForm->process($action, $_REQUEST);

// Return chunk
return $content;

Form chunk code
<form action="" method="post" class="ajax_form af_example">
    
<div class="form-group">
<label class="control-label" for="af_name">af_label_name</label>
<div class="controls">
<input type="text" id="af_name" name="name" value="" placeholder="" class="form-control"/>
<span class="error_name"></span>
</div>
</div>

<div class="form-group">
<label class="control-label" for="af_email">af_label_email</label>
<div class="controls">
<input type="email" id="af_email" name="email" value="" placeholder="" class="form-control"/>
<span class="error_email"></span>
</div>
</div>

<div class="form-group">
<label class="control-label" for="af_message">af_label_message</label>
<div class="controls">
<textarea id="af_message" name="message" class="form-control" rows="5"></textarea>
<span class="error_message"></span>
</div>
</div>


<div class="form-group">
<div class="controls">
<button type="reset" class="btn btn-default">af_reset</button>
<button type="submit" class="btn btn-primary">af_submit</button>
</div>
</div>



</form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
La1serg, 2018-07-07
@La1serg

The submit button must have the name="order" attribute.
In the form you have data validation:
and in the form there are not even such fields (adress, fullname, phone)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question