ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

help with contact form

October 03, 2010 4:25pm

Subscribe [4]
  • #1 / Oct 03, 2010 4:25pm

    johnmck

    31 posts

    I’m trying to email contact form enquiries to staff members, instead of displaying staff email addresses.

    But I’m getting an error on submit:

    Your email had no valid recipients.


    here is the code:

    {exp:email:contact_form user_recipients='false' recipients='{staff_email}' charset='utf-8' user_recipients="true"}
    
    
    <div class='yform'>
    
    <h4>{embed:lang_contact_form}</h4>
    
    <p>            <input type='hidden' name='date' value='{current_time format='%Y %m %d'}' /></p>
    
    <p>            <div class='type-text'><br />
                    <label for='name'>{embed:lang_your_name}:</label><br />
                    <input class="input" type='text' name='name' value='{member_name}' maxlength='60' id='name' size='50' /><br />
                </div></p>
    
    <p>            <div class='type-text'><br />
                    <label for='name'>Telephone:</label><br />
                    <input class="input" type='text' name='telephone' value='' maxlength='60' id='name' size='50' /><br />
                </div></p>
    
    <p>            <div class='type-text'><br />
                    <label for='from'>{embed:lang_your_email}:</label><br />
                    <input class="input" type='text' name='from' value='{member_email}' maxlength='60' id='from' size='50' /><br />
                </div></p>
    
    <p>            <div class='type-text'><br />
                    <label for='subject'>{embed:lang_email_subject}:</label><br />
                    <input class="input" type='text' name='subject' value='{embed:lang_contact_form_subject}' maxlength='60' id='subject' size='50' /><br />
                </div></p>
    
    <p>            <div class='type-text'><br />
                    <label for='message'>{embed:lang_message}:</label><br />
                    <textarea name='message' id='message' cols="50" rows="8"></textarea><br />
                </div></p>
    
    <p>    {if captcha}    <br />
                <div class='type-text'><br />
                    {embed:lang_captcha_instructions} <br />
    {captcha} <input class="input" type="text" name="captcha" value="" maxlength="20" id='captcha' /></p><br />
                    <br />
                </div><br />
        {/if}        </p>
    
    <p>            <div class='type-button'><br />
                    <input class="button" type='submit' name='submit' id="submit" value='{embed:lang_submit}' /><br />
                </div></p>
    
    <p></div>{!-- END YFORM --}<br />
    {/exp:email:contact_form}

  • #2 / Oct 04, 2010 10:41am

    Sue Crocker

    26054 posts

    Hi, John. What is {staff_email}?

  • #3 / Oct 12, 2010 5:29am

    johnmck

    31 posts

    Hi,
    It is a custom field.

  • #4 / Oct 12, 2010 11:30am

    Design by Front

    106 posts

    Hey John,

    In order to use a custom field to populate the user_recipients parameter, you may need to put the contact form into an embedded template and pass the {staff_email} value into it.

    So your first template would have something like:

    {exp:weblog:entries weblog="staff_details" limit="1"}
    {embed=shared/_staff_contact_form email_address="{staff_email}"}
    {/exp:weblog:entries}

    And then in you second template (“shared/_staff_contact_form” in this example):

    {exp:email:contact_form user_recipients='false' recipients='{embed:email_address}' charset='utf-8' user_recipients="true"}
    Your form contents..
    {/exp:email:contact_form}

    Hope this makes sense,
    Chuck

  • #5 / Oct 12, 2010 5:33pm

    Ingmar

    29245 posts

    Thanks for the assist. Does that help, John?

  • #6 / Oct 18, 2010 6:52am

    johnmck

    31 posts

    Hi,
    Turns out it was an issue with the Weblog settings, in having the fields automatically converting to URLs or email addresses.

    Must remember this for future reference.

  • #7 / Oct 18, 2010 8:03am

    Sue Crocker

    26054 posts

    Glad you were able to figure out what the problem was. Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases