• hello everyone,

    I’m trying to make contact form 7 send a autorepsonder email with different content based on dropdown selection. I’m using the hook wpcf7_mail_send in functions.php file to generate autoresponder emails depending on visitor’s choice.

    I have two questions:
    1. how can I force this email to be send as html instead of plain.
    2. the email comes in with www-data from name. can I change it to something else?

    here is the hook I’m using:

    // AUTORESPONDER EMAIL – hook in to wpcf7_mail_sent
    add_action( ‘wpcf7_mail_sent’, ‘contact_form_autoresponders’ );

    #our autoresponders function
    function contact_form_autoresponders( $contact_form ) {

    if( $contact_form->id==205276 ){

    #retrieve the details of the form/post
    $submission = WPCF7_Submission::get_instance();
    $posted_data = $submission->get_posted_data();

    #set autoresponders based on dropdown choice
    switch( $posted_data[‘chosen-company’] ){
    case ‘[email protected]’:
    $msg=”Thank you for contacting ACME Productions. John Smith will contact you shortly.
    Email: [email protected]
    Telephone: 613.555.5555
    Mobile: 613.554.5555″;
    break;

    case ‘[email protected]’:
    $msg=”Thank you for contacting Fun Fuctory. Kit Harrington will contact you shortly.
    Email: [email protected]
    Telephone: 613.555.5555
    Mobile: 613.554.5555″;
    break;

    case ‘[email protected]’:
    $msg=”Thank you for contacting Ski Shop. Dirk Diggler will contact you shortly.
    Email: [email protected]
    Telephone: 613.555.5555
    Mobile: 613.554.5555″;
    break;

    }

    mail( $posted_data[’email’], ‘iNFORMED Partners Program’, $msg );
    }
    }

    any help would be greatly appreciated. thank you.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Have you tried Mail (2)?

    Thread Starter yoshid

    (@yoshid)

    hello takayuki,

    first of all, thank you very much for a fantastic plugin, we have been using it for years now, simple, elegant, perfect!

    I would love to use the native CF7 autoresponder but I am not sure how to send it with different content. we are trying to get visitors to choose a person’s name from a dropdown which uses a (Person Name|[email protected]) which then sends the form to appropriate address.

    the autoresponder needs to have different content depending on the dropdown.

    if there is a way to achieve that with mail_2, could you point me in the right direction? thanks in advance.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    To replace a mail-tag with a custom value, the wpcf7_mail_tag_replaced filter hook would be useful.

    Thread Starter yoshid

    (@yoshid)

    humm, apologies, I don’t think I understand what you mean by replacing wpcf7-mail-tag.
    would you be able to elaborate?

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Replacement of tags is the most basic concept of Contact Form 7’s email generation. For details, see How Tags Work.

    Thread Starter yoshid

    (@yoshid)

    I think you might have misunderstood my question.
    clearly, we can include the dropdown results in mail_2 autoresponder. that however is not the challenge here.

    the autorepsonder email needs to have completely different written content depending on the dropdown, NOT just the value of the dropdown.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Yeah, I understand that. That’s what YOU need to do with the wpcf7_mail_tag_replaced filter function.

    Thread Starter yoshid

    (@yoshid)

    would you be able to provide an example of a filter function that would accomplish what I am trying to do? thank you in advance.

    Thread Starter yoshid

    (@yoshid)

    hello, can anyone help us with this?

    Hello @yoshid;
    I try to do the same thing as you, did you succeed?
    I do not understand the author’s answers. It’s not very clear.
    how does this function “wpcf7_mail_tag_replaced” work?

    Best ragard

    Thread Starter yoshid

    (@yoshid)

    hey cedric, apologies for the late reply.

    we ended up using the script in functions.php I provided below. it’s not ideal but just like you, I did not understand takayuki’s answer.

    if you did find a better solution, I would be grateful if you shared it here.

    merry xmas,
    cheers

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Conditional autoresponder eamil’ is closed to new replies.