The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Change Mime Type Of Email

Labels

This Discussion is public

Notifications

I have a client that is using Goldmine for their CRM and we're using Formidable to collect and send the data to an email that does the import. However, I've been asked to change the mime type of the email to "text/x-gm-impdata". Is there a way programmatically to change the mime type for just this form via a hook or action?

Here is some code that will work for you. I've tested this in my local environment. Do not use a 3rd party SMTP sender with it. The results are unpredictable. For a complete explanation of this code, please see https://victorfont.com/customize-formidable-forms-email-mime-type.

add_filter('frm_pre_create_entry', 'adjust_my_email_header');
function adjust_my_email_header($values){
if ( $values['form_key'] == 'contact2' ) {
add_filter('frm_email_header', 'change_email_content_type');
}
return $values;
}

function change_email_content_type($header) {
/* remove the Content Type element of the array */
array_pop($header);
/* needed to preserve compatibility */
$charset = get_option('blog_charset');
$content_type = 'Content-Type: text/x-gm-impdata; charset="' . esc_attr( $charset ) . '"';
$header[] = $content_type;
return $header;
}

Note that I use form_key instead of form_id. When you migrate a Formidable form to a different environment using export/import, the form id will change. The form key remains static. Using form key will save you a headache tracking down why your code doesn't work after moving to a different environment. Just remember to change the form_key in your code from 'contact2' to the key of your form.

John I did reply you your post with a code snippet, but the reply is awaiting moderation. In the meantime, try this: https://victorfont.com/customize-formidable-forms-email-mime-type

Thanks Victor. I'm going to give this a try.

Discussion closed.