Forums

PHP Dynamic Email Settings

bgareth2 16 Apr, 2013
Hello, I am struggling with the following:

This is what I have placed in the custom code:

<?php
$form->data['from_name'] = "{$form->data['first_name'] ['Surname']}";

{$form->data['from_address'] = "{$form->data['Email_Address']}";

$form->data['subject'] = "{$form->data['first_name'] ['Surname']} has sent you a general enquiry from the Bournemouth and Poole Bipolar UK Website.";
?>


In the dynamic Email settings, I have left the static values blank for the following:

1. Subject
2. from name
3. from email

Instead I have added to the dynamic Email settings the following values:

1. dynamic subject "subject" (without quotes)
2. dynamic from name "from_name" (without quotes)
3. dynamic from email "from_address" (without quotes)
4. dynamic reply to name "from_name" (without quotes)
5. dynamic reply to email "from_address" (without quotes)

When I received the form by Email, it said "Default Subject" (without quotes)and the from Email address and from name were not present.

On the thank you message, it displayed the error message above the thank you message as follows:

Parse error: syntax error, unexpected $end in /home/bpbuk/public_html/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19) : eval()'d code on line 10


Any help would be appreciated,

Kind Regards,

Beanie
GreyHead 18 Apr, 2013
Hi bgareth2,

This line has a stray { at the beginning so will break the PHP:
{$form->data['from_address'] = "{$form->data['Email_Address']}";

And I'm not sure what his snippet is supposed to be but I'm pretty sure it isn't right
{$form->data['first_name'] ['Surname']}
Possibly you meant:
{$form->data['first_name']} {$form->data['Surname']}


Bob
bgareth2 25 Apr, 2013
Hello thanks for your message;

I have replaced the code with the following:

<?php

{$form->data['first_name']} {$form->data['Surname']};

{$form->data['from_address']} {$form->data['Email_Address']};

{$form->data['subject']} {$form->data['first_name'] ['Surname']} has sent you a general enquiry from the Bournemouth and Poole Bipolar UK Website.";
?>


This code is still not working: the error is as follows:

Parse error: syntax error, unexpected '}' in /home/bpbuk/public_html/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19) : eval()'d code on line 3


It wouldn't seem that your replaced code assigns the field to a dynamic form value which can then be used within the dynamic form fields but i'm not very hot in PHP...

Kind Regards,

Beanie.
GreyHead 25 Apr, 2013
Hi Beanie,

The brackets have got in a mess :-( Please try this version:
<?php
$form->data['from_name'] = "{$form->data['first_name']} {['Surname']}";

$form->data['subject'] = "{$form->data['from_name']} has sent you a general enquiry from the Bournemouth and Poole Bipolar UK Website.";
?>

Then use from_name; Email_address and subject in the Dynamic boxes.

Bob

PS The subject looks a bit long to me.
bgareth2 26 Apr, 2013
Hi Bob,

Thanks for this,

I have just noticed though that there is no assignment for the Email Address and the Surname is not included within the subject, have I made a mistake in thinking this would be needed in your suggested code above?

Thanks again for your help!

Kind Regards,

Beanie.
GreyHead 26 Apr, 2013
Hi Beanie,

Did you try this version?

The Surname is included in the Subject - it's part of the 'from_name' that is defined in the first line.

The Email assignment does nothing useful except declare a new variable with a different name. I suggested that you use Email_address in the From email box.

Bob

PS I strongly recommend that you do *not* use the Dynamic From Email element in your Email Setups. Using this often results in your emails being marked as spam and dropped into a spam filter. Instead use the static From Email with an address that matches the site domain name and use Dynamic ReplyTo Email for the user email. The result is the same but with a much better chance of good delivery.
bgareth2 08 Jun, 2013
Thanks for all your help,

I am starting to get somewhere!

The main issue I am now having is that, because I have set up two Emails on the events, the first to send the Email to us, the second to send the Email to them, a copy of the added text before the Email is actually being sent to us when it is intended for the person who submitted the form. So, for example:

Dear Sir,

Thank you for your Email to us. We will reply shortly.

is going to our Email address as well as the person who completes the form despite there being a separate Email event set up to Email the information to us. Essentially the text before and after the submitted form should be different for the Email that goes to us and the Email that they receive.

I am not sure if the issue is with the field name I am using of "Email_Address".

The configuration I am using is as follows for the form that should be Emailed to us:

Static:

To: Our Email Address
Subject: General Enquiry from BPBUK Website
From Name: BPBUK Website
From Email: webmaster@bpbuk.org.uk


Dynamic:

No Details entered.

The configuration I am using is as follows for the Form that should be Emailed to the person who completes it:

Static:

Subject: Your General Enquiry
From Name: Bipolar UK Bournemouth and Poole
From Email: webmaster@(domain)
(Our Email Address)

Dynamic:

To: Email_Address
Dynamic Reply To Name: first_name Surname
Dynamic Reply To Email: Email_Address


Any information not specified in the configuration has been left blank.

Could this be because the actual Email that should be sent to us is not working properly and is falling back to the Email that should be sent to them?

Thanks for your help,

Beanie.
bgareth2 08 Jun, 2013
I have just tested the form and the issue is actually that we are receiving a copy of the form that is sent to the sender. I'm not quite sure why as we receive our own copy because of the second Email action anyway...

Thanks,

Beanie.
GreyHead 08 Jun, 2013
Hi Beanie,

Is this Joomla! 3? In that case there is a known bug with the standard Email action; at present the fix is to use my Email [GH] action

Bob
bgareth2 08 Jun, 2013
Hey Greyhead :-) Thanks for your help as always!

I've tried to install this in extension manager and I have got the following error:

"JInstaller: :Install: Cannot find XML setup file".

Once I have installed it, will it just add extra functionality to the existing Email Actions or do I need to create a totally new action for each of the Emails, bit out of my depth here if it requires custom coding or programming :-)

Thanks again and have a lovely weekend,

Beanie.
GreyHead 08 Jun, 2013
Hi Beanie,

Please use the Install Action icon in the ChronoForms Forms Manager Toolbar. It will then appear as a new action in your Actions list in the [GH] Custom Actions group (in the Normal Wizard). You can drag a copy into your form like any other action. See the Help tab of the action for more info. It is similar to the standard Email action but more flexible. The biggest difference is that there is no Static & Dynamic tabs, you can put e.g. {email_input},user@example.com in the same box.

Bob
bgareth2 12 Jun, 2013
Thanks as always Greyhead :-) I'll have a look at this later. I've been having a few problems with getting the Honeypot Spam setup working - it's pretty genius and I've followed all the instructions at - http://www.chronoengine.com/faqs/2699-how-can-i-add-a-honeypot-spam-check.html

The only small problem i'm having is that I have a loop set up (just using the actions available rather than any custom code) to:

On Submit:

Custom Code (for the honeypot)
Check Captcha
Email Me
Show Thanks Message
Email Sender

On Fail:

Load Captcha
Show HTML.

The only small problem is the confirm box becomes visible if the person filling in the form types the captcha wrong and it reloads. I did think to add the Load CSS Event somewhere else as well within the loop but i'm not sure :-S

Thanks :-)
GreyHead 12 Jun, 2013
Hi bgareth2,

I'm not clear what the On Fail event is here? Normally you'd just use an Event Loop action in the On Fail event of the Check Captcha action to re-load the form's On Load event. Does that work?

Bob
keske 25 Nov, 2013
Hi Bob,

Works like a charm. Thank you.
Just bought you a beer.

Have a good day.

Greetings Kees van Dongen
The Netherlands
GreyHead 26 Nov, 2013
Hi Kees,

Thank you, much appreciated.

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