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

Hey everyone, I’m having trouble with Contact Form 7 and WP Mail SMTP. The form is sending emails fine, but the mail tags in the message body aren’t working anymore. This started after I switched to using the Gmail API with WP Mail SMTP to fix some delivery issues.

Here’s what’s weird:

  • The form and tags are exactly the same as before
  • Emails are getting through now (yay!)
  • But the message body is empty except for the actual message

I’ve double-checked that my form fields match the tags in the message body setup. The subject line comes through okay, but nothing else shows up.

Has anyone else run into this? Any ideas on how to get those tags working again with this setup? I really need the sender’s name and email to show up in the messages I receive.

Thanks for any help you can offer!

I encountered a similar issue when switching to the Gmail API with WP Mail SMTP. After some troubleshooting, I found that the problem was related to how the Gmail API processes the email content. To resolve this, I had to modify the email format in Contact Form 7 to use HTML instead of plain text.

Try editing your Contact Form 7 email template and wrapping the content in HTML tags. For example:

<html>
<body>
<p>From: [your-name] <[your-email]></p>
<p>Subject: [your-subject]</p>
<p>Message Body: [your-message]</p>
</body>
</html>

This approach helped me get the mail tags working correctly with the Gmail API. Also, ensure that you’ve updated to the latest versions of both plugins. If the issue persists, you might want to check the WP Mail SMTP logs for any specific errors or conflicts.

I’ve dealt with this exact issue before, and it can be frustrating. One thing that worked for me was adjusting the Content-Type header in the WP Mail SMTP settings. Make sure it’s set to ‘text/html’ instead of ‘text/plain’. This tells Gmail to interpret the email content as HTML, which often resolves tag rendering problems.

Another trick is to double-check your mail tag syntax. Sometimes, switching mail providers can be picky about exact formatting. Try using square brackets consistently, like [your-name] instead of {your-name}.

If those don’t work, you might need to dive into the WP Mail SMTP plugin’s code. Look for any functions that might be stripping out HTML or processing the email body. Sometimes, there’s a filter you can add to your theme’s functions.php to preserve the tags.

Lastly, test with a simple form first to isolate the issue. Good luck troubleshooting!

hey sophia, i had da same problem. try checkin ur wp-config file for any weird stuff. sometimes old smtp settings hang around there n mess things up. also, make sure ur form is set to send html emails, not plain text. that fixed it for me. good luck!