Forums

Blocking emails to certain domains with Chronoforms

simonshah 31 Jul, 2009
Is there any way to block emails to form registrants that have specific email domains> For exmaple, lete say we didnt want to send a post form submission email to users that had an email address as xxxx:aol.com and xxxx.yahoo.com but send emails to other form registrants. Is there a way to do this?
GreyHead 31 Jul, 2009
Hi simonshah,

Yes, you'd need to add some on-submit before code to check the email address and stop the email for those you didn't want to send to. I forget the code but I think it's possible to turn the email off - or you could just replace the email with [email]dump@example.com[/email]

Bob
nml375 05 Aug, 2009
Hi,
You could use something like this to disable the first email completely whenever 'email' contains any of the parts listed in $patterns. This would have to go into 'serverside validation' or on 'submit before email' boxes. Be adviced that this will not block any other processing of the submitted data. (use the 'serverside validation' box and return an error message to prevent any further processing of the submitted data).
$pattern = '@yahoo.com,@aol.com':
$email = JRequest::getString('email');
foreach (explode(',', $pattern) as $item)
{
  if (strstr($email, $item))
  {
    $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
    /* Set the 'enabled' property to 0 for the 1st email */
    $MyFormEmails->setEmailData(1, 'enabled', '0');
  }
}


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