Hello,
is there a way to restrict email-actions from private senders like gmail, hotmail, gmx eg.?
Thx!
is there a way to restrict email-actions from private senders like gmail, hotmail, gmx eg.?
Thx!
Hi contour,
Yes, you can probably do this with an Event Switcher action - but what exactly do you need to do?
Bob
Yes, you can probably do this with an Event Switcher action - but what exactly do you need to do?
Bob
Hi Bob,
my customer dont want to get Emails from private accounts. So in the form at the website we have a textfield where the sender has to put his email adress in. I have a list of domains, that my customer dont want to receive email requests via chronoforms from like gmx, aol and so on.
so whenever the input of the email-field is from a private account, the email should not be sent.
my customer dont want to get Emails from private accounts. So in the form at the website we have a textfield where the sender has to put his email adress in. I have a list of domains, that my customer dont want to receive email requests via chronoforms from like gmx, aol and so on.
so whenever the input of the email-field is from a private account, the email should not be sent.
Hi contour,
OK - so you can do that with the Event Switcher, create an array of 'invalid' domains, compare the email to the array. If there is no match then trigger the Event Switcher event and add the Email action to that.
To do this drag in an Event Switcher to the On Submit event of your form; open it up and put send_email in the Events box; save it, re-open for editing and Click Load events, then save again and you should see a new send-email event. You can drag your Email action there.
In the Event Switcher add PHP to check the email and - if it's good return 'send_email'; otherwise do nothing.
Bob
OK - so you can do that with the Event Switcher, create an array of 'invalid' domains, compare the email to the array. If there is no match then trigger the Event Switcher event and add the Email action to that.
To do this drag in an Event Switcher to the On Submit event of your form; open it up and put send_email in the Events box; save it, re-open for editing and Click Load events, then save again and you should see a new send-email event. You can drag your Email action there.
In the Event Switcher add PHP to check the email and - if it's good return 'send_email'; otherwise do nothing.
Bob
Is there a more detailed description or manual how to do what you described above?
Hi contour,
There are some descriptions in the forums here on using the Event Switcher - but this is the first time I've seen this particular use suggested.
Bob
There are some descriptions in the forums here on using the Event Switcher - but this is the first time I've seen this particular use suggested.
Bob
Hey Bob,
I didnt use to learn php anyway. May you can give me the example of the php code with one domain, so I can add the others to myself. Would that be possible?
Kind regards
I didnt use to learn php anyway. May you can give me the example of the php code with one domain, so I can add the others to myself. Would that be possible?
Kind regards
Is the action-label of the event-switcher a name, that i create individually or is it the place where to link with the php-action with the email field? If not, how do I link event-switcher with the email field?
Hi contour,
The Event Switcher action/event names are created with the Events box in the action.
The PHP needs to be written to meet your specific needs but it will be something like this:
Bob
[[>> later : fixed typo <<]]
The Event Switcher action/event names are created with the Events box in the action.
The PHP needs to be written to meet your specific needs but it will be something like this:
<?php
$no_email = array(
'@gmail',
'@hotmail',
. . .
);
$send_email = true;
foreach ( $no_email as $e ) {
if ( strpos($form->data['email']) !== false ) {
$send_email = false;
break;
}
}
if ( $send_email ) {
return 'send_email';
}
?>
Bob
[[>> later : fixed typo <<]]
Hi Bob,
at first: Thanks a lot for your help! My code now looks like this:
And it shows me this error message:
Parse error: syntax error, unexpected '{' in /kunden/225921_93047/webseiten/kunden/amicra/html/2015/administrator/components/com_chronoforms5/chronoforms/actions/event_switcher/event_switcher.php(26) : eval()'d code on line 42
Line 42 is the following:
if ( strpos($form->data['email'] !== false ) {
Is there a mistake in that line? As I Told you I´m not experienced in php-programming.
Thank you!
at first: Thanks a lot for your help! My code now looks like this:
<?php
$no_email = array(
'att.net',
'comcast.net',
'cox.net',
'earthlink.net',
'facebook.com',
'gmail.com',
'gmx.com',
'gmx.de',
'gmx.net',
'googlemail.com',
'hotmail.co.uk',
'hotmail.com',
'hotmail.de',
'hushmail.com',
'inbox.com',
'juno.com',
'live.com',
'live.de',
'mac.com',
'mail.com',
'me.com',
'msn.com',
'o2.co.uk',
'online.de',
'rocketmail.com',
'sbcglonal.net',
'sky.com',
't-online.de',
'verizon.net',
'web.de',
'yahoo.co.uk',
'yahoo.com',
'yandex.com',
'ymail.com',
'yahoo.de',
'zoho.com',
);
$send_email = true;
foreach ( $no_email as $e ) {
if ( strpos($form->data['email'] !== false ) {
$send_email = false;
break;
}
}
if ( $send_email ) {
return 'send_email';
}
?>
And it shows me this error message:
Parse error: syntax error, unexpected '{' in /kunden/225921_93047/webseiten/kunden/amicra/html/2015/administrator/components/com_chronoforms5/chronoforms/actions/event_switcher/event_switcher.php(26) : eval()'d code on line 42
Line 42 is the following:
if ( strpos($form->data['email'] !== false ) {
Is there a mistake in that line? As I Told you I´m not experienced in php-programming.
Thank you!
Hi Contour,
Sorry, I missed a ) in this line
Bob
Sorry, I missed a ) in this line
if ( strpos($form->data['email'] !== false ) {
:-(
Bob
Even if I change that, clear browser cache etc. its still this error reporting:
Parse error: syntax error, unexpected '{' in /kunden/225921_93047/webseiten/kunden/amicra/html/2015/administrator/components/com_chronoforms5/chronoforms/actions/event_switcher/event_switcher.php(26) : eval()'d code on line 42
this is Line 42 of the event_switcher.php from serverpath:
jQuery('#cfaction_event_switcher_element_'+SID).children('.panel-body').append(events_html);
Parse error: syntax error, unexpected '{' in /kunden/225921_93047/webseiten/kunden/amicra/html/2015/administrator/components/com_chronoforms5/chronoforms/actions/event_switcher/event_switcher.php(26) : eval()'d code on line 42
this is Line 42 of the event_switcher.php from serverpath:
jQuery('#cfaction_event_switcher_element_'+SID).children('.panel-body').append(events_html);
I checked the new code with the code you just gave me, where a ( is missing. Both codes are identic. See below:
if ( strpos($form->data['email'] !== false ) {
if ( strpos($form->data['email'] !== false ) {
Can you give me the right one🙂
if ( strpos($form->data['email'] !== false ) {
if ( strpos($form->data['email'] !== false ) {
Can you give me the right one🙂
Hi contour,
Sorry, It looks like I closed the window before it saved my edit:
Bob
Sorry, It looks like I closed the window before it saved my edit:
if ( strpos($form->data['email']) !== false ) {
Bob
After chancing, saving, and testing it give me that:
Warning: strpos() expects at least 2 parameters, 1 given in /kunden/225921_93047/webseiten/kunden/amicra/html/2015/administrator/components/com_chronoforms5/chronoforms/actions/event_switcher/event_switcher.php(26) : eval()'d code on line 42
So sorry! :/ I would love to have an idea on my own how to fix this.
Warning: strpos() expects at least 2 parameters, 1 given in /kunden/225921_93047/webseiten/kunden/amicra/html/2015/administrator/components/com_chronoforms5/chronoforms/actions/event_switcher/event_switcher.php(26) : eval()'d code on line 42
So sorry! :/ I would love to have an idea on my own how to fix this.
Hi contour,
Sorry, I don't usually get so many bugs in one line of code :-(
Bob
Sorry, I don't usually get so many bugs in one line of code :-(
<?php
$no_email = array(
'att.net',
'comcast.net',
'cox.net',
'earthlink.net',
'facebook.com',
'gmail.com',
'gmx.com',
'gmx.de',
'gmx.net',
'googlemail.com',
'hotmail.co.uk',
'hotmail.com',
'hotmail.de',
'hushmail.com',
'inbox.com',
'juno.com',
'live.com',
'live.de',
'mac.com',
'mail.com',
'me.com',
'msn.com',
'o2.co.uk',
'online.de',
'rocketmail.com',
'sbcglonal.net',
'sky.com',
't-online.de',
'verizon.net',
'web.de',
'yahoo.co.uk',
'yahoo.com',
'yandex.com',
'ymail.com',
'yahoo.de',
'zoho.com',
);
$send_email = true;
foreach ( $no_email as $e ) {
if ( strpos($form->data['email'], $e) !== false ) { // change this line again
$send_email = false;
break;
}
}
if ( $send_email ) {
return 'send_email';
}
?>
Bob
Hi Bob,
dont mind anyway😉 Im glad you´re helping me out. So I changed the code completely, did a test. And it looks like message has been sent even if I put my googlemail.com adress in the email field.
URL tells me that the message has been sent (I guess): ...&event=submit
Usually I get an message-sent notification - not in that case. Module position where the form is displayed is blank then.
And I checked my inbox. Nothing arrived. So message probably has not been sent at all.
And normally I think there should be an event loop and also an error message, to tell the user that sending the form with a private email input is not possible.
See my event-structure. Is there anything wrong?
dont mind anyway😉 Im glad you´re helping me out. So I changed the code completely, did a test. And it looks like message has been sent even if I put my googlemail.com adress in the email field.
URL tells me that the message has been sent (I guess): ...&event=submit
Usually I get an message-sent notification - not in that case. Module position where the form is displayed is blank then.
And I checked my inbox. Nothing arrived. So message probably has not been sent at all.
And normally I think there should be an event loop and also an error message, to tell the user that sending the form with a private email input is not possible.
See my event-structure. Is there anything wrong?
Hi contour,
First off, test using the Test Form or View Form links from the Forms Manager, when tha tis working OK test again from a module location. That just keeps the debugging simpler.
I would structure this differently - though the structure you have should work. This reduces the nesting and makes the flow clearer.
Bob
First off, test using the Test Form or View Form links from the Forms Manager, when tha tis working OK test again from a module location. That just keeps the debugging simpler.
I would structure this differently - though the structure you have should work. This reduces the nesting and makes the flow clearer.
On Submit
Check Captcha
+ on Success - leave empty
+ on Fail - Event Loop
Event Switcher
+ on no_email (new event) - show message + event loop
After the Event Switcher
Email 1
Email 2
Thanks Message
Debugger - for debugging
Adding a Debugger action(s) and debug code can help you track exactly what is happening and pin down where an error is occurring.
Bob
Hi Bob,
today I tried your ordering of events. The form was sent correctly with all attachments but its still not restricting my googlemail account and leads me to my display message.
Events in the Event-Switcher are: send_email, no_email. See picture. Is that right?
The On send_email is empty. See picture. Is that right?
This is the code of the event-switcher:
today I tried your ordering of events. The form was sent correctly with all attachments but its still not restricting my googlemail account and leads me to my display message.
Events in the Event-Switcher are: send_email, no_email. See picture. Is that right?
The On send_email is empty. See picture. Is that right?
This is the code of the event-switcher:
<?php
$no_email = array(
'att.net',
'comcast.net',
'cox.net',
'earthlink.net',
'facebook.com',
'gmail.com',
'gmx.com',
'gmx.de',
'gmx.net',
'googlemail.com',
'hotmail.co.uk',
'hotmail.com',
'hotmail.de',
'hushmail.com',
'inbox.com',
'juno.com',
'live.com',
'live.de',
'mac.com',
'mail.com',
'me.com',
'msn.com',
'o2.co.uk',
'online.de',
'rocketmail.com',
'sbcglonal.net',
'sky.com',
't-online.de',
'verizon.net',
'web.de',
'yahoo.co.uk',
'yahoo.com',
'yandex.com',
'ymail.com',
'yahoo.de',
'zoho.com',
);
$send_email = true;
foreach ( $no_email as $e ) {
if ( strpos($form->data['email'], $e) !== false ) {
$send_email = false;
break;
}
}
if ( $send_email ) {
return 'send_email';
}
?>
Hi contour,
You only need the one 'no_email' event - though the second one is harmless. The code at the end needs to be
Bob
You only need the one 'no_email' event - though the second one is harmless. The code at the end needs to be
if ( !$send_email ) {
return 'no_email';
}
?>
At present you are calling the send_email event which does nothing.
Bob
This topic is locked and no more replies can be posted.