Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Can't get contact form to work

This discussion is related to the Contact addon.

So I installed the plugin and tested it out by essentially trying to submit a message and kept getting back the following message in red above the form:

"You must provide at least one recipient email address."

I was using valid email addresses in the email field so not sure why it's not working.

The contact form is located here if you want to see what I'm talking about.

Any thoughts on this problem?

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Yes very odd it is not supposed to do that , there is nothing extra in that code to make that happen. I think something is preventing from registering the input.

    This is the part which controls those error messages , it validates if there was something entered.See if yours is the same .

    
    if($Sender->Form->IsPostBack() != False){
                $Validation = new Gdn_Validation();
                $Validation->ApplyRule('YourName', 'Required', 'You must enter your name.');
                $Validation->ApplyRule('YourEmail', 'Email', 'You must enter your e-mail (will not be published).');
                $Validation->ApplyRule('Message', 'Required',"You must include a Message");
                $FormValues = $Sender->Form->FormValues();
                $Validation->Validate($FormValues);
                $Sender->Form->SetValidationResults($Validation->Results());
                if($Sender->Form->ErrorCount() == 0){
                    $Name = $FormValues['YourName'];
                    $Subject = sprintf('Contact From %s %s', $Name, date('j M Y H:i'));
                    $Email->Subject($Subject);
                    $Email->To( C('Garden.Email.SupportAddress', ''));
                    $Email->From($FormValues['YourEmail']);
                    $Email->Message($FormValues['Message']);
                
                    try{
                        $Email->Send();
                    }catch(Exception $Exception){
                
                        $Sender->Form->AddError(strip_tags($Exception->GetMessage()));
                    }
    
                    if($Sender->Form->ErrorCount() == 0){
                        $Sender->StatusMessage = T('Thank you for your message.');
                        $Sender->RedirectUrl = Url("/");
                    }
                }
            
    }
    
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I just installed this on another forum from the downloads and it works for me. All I can think of is that there is something you have on there interfering with the form.

  • The only thing you can do is some debugging. Show the variables by using print_r and var_dump

    vrijvlinder
  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited July 2013

    @ZombieBoy
    I think your problem is you have not set up the recipient email where this mail should go. That means your email the email you need to put into the config.php

    $Configuration[Garden][Email][SupportAddress]='[email protected]';

    demsley
  • @vrijvlinder
    Oh man, yes that was it. I just realized I hadn't put my email address in the "Outgoing Mail" section of the Settings menu. Ugh, that was a boneheaded and obvious error. And here I was wracking my brain trying to figure it out.

    Thanks so much for your help!

    vrijvlinder
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    You should download the new version it has a checkbox to help avoid spam by bots.

    UnderDogdemsley
Sign In or Register to comment.