Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] craft different email bodies for "to" recipient and "copysender" recipient. #43

Open
maniqui opened this issue Feb 6, 2017 · 1 comment

Comments

@maniqui
Copy link

maniqui commented Feb 6, 2017

Feature request: to be able to craft different email bodies for contact form recipient and “copysender” recipient.

Use case: you may want to have some hidden/secret fields on your contact form message and only include them on the email sent to the contact form recipient, while excluding them from the “copysender” recipient. Or maybe you want to add some extra message for the “copysender” recipient so to explain him why is he receiving a copy of the email or whatever.

I thought that testing for copysender value inside body_form could be a solution, but I checked the plugin source code and it seems that the $msg payload is the same for both messages.

Thanks.

@trenc
Copy link

trenc commented Mar 8, 2017

You can do this by hooking into zemcontact.deliver.

If I'm not missing something, this should do the trick.

register_callback('yab_send_cc', 'zemcontact.deliver');                              
                                                                                    
/*
 * use <txp:zem_contact_secret name="yab_send_cc" value="email_body_form" /> in a 
 * zem_contact_form to send a CC-Mail, where value is txp form as mail body template
 */
function yab_send_cc($step, $pre, $payload)
{
  global $zem_contact_values;

  $flags = array('yab_send_cc');

  extract($payload);                                                                

  // handle copysender and plugin flag                                              
  if ($pre === 'copysender' and isset($fields['yab_send_cc']))
  {
    $body = parse_form($zem_contact_values['yab_send_cc']);

    foreach($flags as $flag)
    {
      unset($fields[$flag]);
    }

    if (zem_contact_deliver($to, $subject, $body, $headers, $fields, array('isCopy' => false)))
    {
      return 'zemcontact.skip';
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants