Forums

Stop Form from sending email

ljk 08 Aug, 2013
Hi,

We are using chronoforms 3.2 on a Joomla 1.5 site. We have a captcha, but still getting lots of spam.

What I would like to do is check the Message textarea field, in the "On Submit - before sending email" field, and if there is a URL in the message not send the email to the site owner or the autoreply to the submitter. How do I stop the emails from being sent if I determine there is 'bad' data in the message field?

The textarea message field is defined like so:
<textarea class="cf_inputbox required" rows="6" id="message" title="Please send us your message" cols="30" name="message"></textarea>


I believe I would get the textarea field like so:
$message = JRequest::getString('message', '', 'post');

I can then check the message and determine if I want to stop the emails from being sent. I just don't know how to stop the email processing from continuing.

Thank you.
GreyHead 10 Aug, 2013
Hi ljk,

The code to conditionally disable an email is on Chapter 12 page 340/341 of the ChronoForms book assuming that you can find your copy.

Alternatively you could use Severside validation with a regexp to look for URL and check and block the mails at that stage.

Bob
ljk 12 Aug, 2013
Hi,

Thank you. Got that to work.
ljk 03 Sep, 2013
Hi Bob,

Now I would like to do the same thing for Joomla 2.5 and Joomla 3 sites using V4 of chronoforms.

In V3 and Joomla 1.5 I used this code:

			$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
			$MyFormEmails->setEmailData('1', 'enabled', false);

What would be the equivalent for V4?

I have an On Submit event that has a custom code event, which checks things. This is where I would want to have the code to stop the emails, but the email events are after the custom code event. I have attached the contact form if that helps.

Thanks for any help on this.
GreyHead 04 Sep, 2013
Hi ljk,

The simplest solution is to get my Email [GH] action which has a 'Conditional' option which you can use to send an email (or not) depending on a form value.

Bob
This topic is locked and no more replies can be posted.