• Skip to main content

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

Call Us:

+1 919-604-5828

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network
You are here: Home / Computers and Internet / Customize Formidable Forms Email Mime Type

Customize Formidable Forms Email Mime Type

By Victor M. Font Jr.
June 23, 2017Leave a Comment

On the Formidable Forms Community Support Forum, a customer asks,

How do I change the mime type of an email to text/x-gm-impdata so the content can be imported into Goldmine?

Formidable uses the WordPress wp_mail() function to send emails. Unless otherwise specified, the wp_mail function defaults the content type (mime) of any email to text/plain. The function provides a filter that allows you change the content type. The filter is wp_mail_content_type. To change the mime type for all emails, you would use:

Unfortunately, I've tested this and it doesn't work with Formidable. Instead of using the WordPress supplied filter, Formidable hard codes the mime type as 'text/plain' or 'text/html'. Formidable also has an undocumented filter called frm_email_header that we can use to manipulate the content or mime type. If we examine the output of this filter, just prior to Formidable's call to wp_mail, the header contains a three element array that has the following content (as viewed with the Kint debugger):

The value of the third element will either be Content-Type: text/html; charset="UTF-8" or Content-Type: text/plain; charset="UTF-8". Knowing this, we can change the mime type prior to the send action. Since this is a simple array, the way to do this is to remove the third element and replace it with the new content type. The code looks like this:

This works perfectly, but it changes the mime type for all emails sent by Formidable. So this needs to be wrapped in code that limits it to the specific form. This also may not work at all if you are using a 3rd party SMTP server such as Mandrill or Sparkpost. When I was testing this code in my local environment, I had Sparkpost enabled and Sparkpost kept changing the content type back to text/html. My recommendation is not to use any 3rd party SMTP sender with this process.

The last step is to wrap the apply frm_email_header filter in a formidable hook that fires after submit but before the email is sent. For this we can use the frm_pre_create_entry hook.

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.

If this all works for you, viewing the email source code will display a header similar to this one:

  • 12shares
  • Facebook6
  • Twitter0
  • Pinterest2
  • LinkedIn2
  • Print
  • SMS0

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Reader Interactions

VictorFont.com runs on the Genesis Framework

Genesis FrameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Check out the incredible features and the selection of designs. It's that simple—start using Genesis now!

Click here to download The Genesis Guide for Absolute Beginners (PDF - 1.4 MB)

Leave a Reply Cancel reply

Your email address and website will not be published. Required fields are marked *
Posting a comment means that you agree with and accept our Comment & Product Review Policy

Call: +1 919-604-5828

Send us an E-mail

Accessibility Statement | Affiliate Marketing Disclosure | Capability Statement

Cookie Policy | Comment & Product Review Policy | Privacy Policy | Site Map | Terms & Conditions

Copyright © 2003–2023 Victor M. Font Jr.

Return to top of page