Contact Form 7 message tags not working with Gmail API in WP Mail SMTP plugin

Hey everyone, I’m having trouble with my contact form. I use Contact Form 7 and recently switched to WP Mail SMTP with Gmail API to fix some email delivery problems. Now my emails are getting through, but the message tags in Contact Form 7 aren’t working anymore.

The form itself is fine and hasn’t changed. It’s got fields for name, email, subject, and message. The weird thing is, when I get an email from the form, it only shows the message. All the other details like the sender’s name, email, and subject are missing.

I’ve double-checked the Message Body in Contact Form 7’s Mail tab. It’s set up to include all the info, but it’s just not showing up in the actual emails.

Has anyone else run into this? Any ideas on how to fix it? I’m stumped!

I encountered a similar issue when integrating Contact Form 7 with WP Mail SMTP. One often overlooked solution is to verify the ‘From’ email address in your Contact Form 7 settings. Ensure it matches the email address you’ve authenticated with Gmail API in WP Mail SMTP. If they don’t match, Gmail may strip out certain parts of the email content for security reasons.

Another potential fix is to review your WP Mail SMTP settings. Make sure you’ve enabled the ‘Force From Email’ option. This can sometimes resolve conflicts between the plugin and Contact Form 7’s email handling.

If these don’t work, you might need to add some custom code to your functions.php file to modify how CF7 interacts with WP Mail SMTP. It’s a bit advanced, but it’s worth looking into if simpler solutions don’t pan out.

ive had similar issues with cf7 and wp mail smtp. check ur mail content type setting in cf7. if its html, switch to plain text. that fixed it for me. also, double check ur message body format in cf7 mail settings. sometimes the tags get messed up. good luck!

I’ve dealt with this exact problem before. The issue might be in how WP Mail SMTP is processing the email headers from Contact Form 7. Here’s what worked for me:

First, try adding this to your wp-config.php file:

define(‘WPMS_ON’, true);

This forces WordPress to use the SMTP settings for all emails.

If that doesn’t work, you might need to dive into the code a bit. I had to add a filter to my functions.php to preserve the CF7 headers:

add_filter(‘wp_mail’, function($args) {
$args[‘headers’] = array(‘Content-Type: text/html; charset=UTF-8’);
return $args;
});

This ensures that the email content type is set correctly and should preserve your CF7 tags.

Last resort, consider switching to a different SMTP plugin. I’ve had good luck with Post SMTP in similar situations. Sometimes a fresh start is the easiest fix.