Forums

SOLVED No to, from, or subject when php in email template

jennifer 16 Oct, 2010
I have a form set up in ChronoForms. I have entered all the necessary info in email setup and the box turns green. I have turned off the visual editor. I have enabled the sending of emails in the general tab. I have my form in debug mode.

When I let ChronoForms fill in the email template with the default content from my form, the email to, from, and subject show up above the email content on the debug page. If I turn off debug, the system sends me an email, just like it is supposed to. So I know the system is working.

However, when I replace the default content of the email template with my php code, the to, from, and subject are blank and I get the message "You must provide at least one recipient e-mail address." at the top of the page. My email content shows up just like it is supposed to look with no errors in the debug screen. I know I am missing something simple. Is there an extra piece of code I need to add?

I have searched the forums here repeatedly, but I can't find an answer to this.
jennifer 16 Oct, 2010
After further troubleshooting, I have discovered that the problem seems to be the php tags (<?php ?>). If I remove them, I get the to, from, and subject and the emails are sent. Of course, then the email content is php code.

I have looked at several posts regarding php in the email template, and they all seem to say that you don't need to do anything special, just put the php code in the template.

I also forget to add before that I am using ChronoForms 3.1 RC5.5.
GreyHead 17 Oct, 2010
Hi jennifer,

To use PHP in the Email template you have to set 'Use Template Editor' to 'No' in the Email Setup | Properties box. Otherwise the Template Editor mangles the code.

Bob
jennifer 17 Oct, 2010
Thanks for the reply and the suggestion, GreyHead. I have turned off the template editor. That is not my problem. The php is presented flawlessly with no errors. I just can't get any to, from, or subject when using it.
GreyHead 17 Oct, 2010
Hi jennifer,

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
jennifer 17 Oct, 2010
Thank you for being so generous with your time and skills. Here is the backup.
GreyHead 19 Oct, 2010
Hi jennifer,

Found it :-)

The problem is using $email in the form HTM over-writes the ChronoForms $email object :-(

Replace $email with $client_email and all is well again.

Bob
jennifer 19 Oct, 2010
Bob,

You are my hero!

Thank you so much. I have looked at this for hours and hours. I'm not sure I would have ever seen that. I am grateful you took the time to look at it.

Jennifer
GreyHead 19 Oct, 2010
Hi Jennifer,

Just because it may help in the future here's the process I used:

[list]
  • I turned off anything unnecessary (the second email and the anti-spam)
  • I set the site Error Reporting to Maximum to see if there were any PHP Errors reported (lots of noticed but no errors)
  • I removed the email template code completly and checked that the debug report then showed the Email details correctly (it did)
  • I pasted a copy of the template code into Dreamweaver to check for PHP syntax errors (none found)
  • I pasted back about half of the form HTML to check if the error was in that part - taking care not to break the PHP too much (it was in the first half)
  • I removed more chunks of the template code until just the list of variables was left; then I looked through tese for any likely cause and spotted $email
  • Changed the variable name, checked that the error was removed and replaced the rest of the code (with the new variable name).
  • [/list]

    Bob
    adokilla 20 Oct, 2010
    Hello,

    I am new to here and saw this post its similar to what i am having an issue with. I have
    created a form that includes a name, email, subject and few other fields. My issue is when someone submits the form, In my inbox email it shows from : [email]sales@mydomain.com[/email] ( not the address from which the user put in the email field and the same with the subject field).

    Thank you for the support
    GreyHead 21 Oct, 2010
    Hi adokilla,

    If you want to add the User's Name and email then *add* the Dynamic ReplyTo Name & Dynamic ReplyTo Email to the Email setup and put the names of the form inputs that hold that information into the boxes for these two elements.

    Bob
    adokilla 21 Oct, 2010
    Thanks Bob, i have tried but i get the email but the issue is that now the email contains this error message From Invalid Address Undisclosed Recipients.

    I have attached a screen shot of what i have put it, but if i try to change the fields Dynamic Reply To Name & Dynamic Reply To Email i cant save the form and it doesn't turn green.

    Thank you very much for all the help Bob!
    GreyHead 21 Oct, 2010
    Hi adokilla,

    Put the field names in without any brackets or quotes e.g text_2 .

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