Send e-mail confirmation after submitting external form

Hi there,

Can anyone explain to me how to send an e-mailconfirmation when a form is submitted by the user? I'm trying to develop this piece of functionality based on the test_form which is default shipped in Concrete5-5.7. Thanks in advance.

Kind regards,

View Replies: View Best Answer
hutman replied on at Permalink Reply
In your controller after you do all your validation and whatever you can add something like this

$bodyHTML = '<p>This is the body of the email.</p>';
$mh = Loader::helper('mail');
$mh->to('[email protected]'); 
$mh->from('[email protected]'); 
$mh->setSubject(t('Email Subject'));
hencovanee replied on at Permalink Reply
Hi hutman,

Thanks for your reply! Unfortunately my PHP skills are not that wel developed, so I hope you are willing to help a step further.

Enclosed you find the code of the test_form.php. Could you please give me a hint where to place the mentioned code in the php file. Just to see how the e-mail piece will work. From that point on I think I am able to develop the form as I want to.


namespace Concrete\Block\ExternalForm\Form\Controller;
use Concrete\Core\Controller\AbstractController;
class TestForm extends AbstractController
    public function action_test_search($bID = false)
        if ($this->bID == $bID) {
            $this->set('response', t('Thanks!'));
            return true;
    public function view()
        $this->set('message', t('This is just an example of how a custom form works.'));
hutman replied on at Permalink Best Answer Reply
I'm not exactly sure what you are trying to do, but if you put that in the action_test_search function it will send an email each time the form is submitted. You'll need to update the to and from email addresses.
hencovanee replied on at Permalink Reply
Thanks again, will try that!