Using Code Snippets

Summarize:ChatGPTPerplexity

Would you like a simple, one-click way to add custom code snippets to your site? With WP Mail SMTP and the WPCode plugin, you can install ready-made code snippets without editing your theme’s functions.php file.

In this tutorial, we’ll show you how to use WP Mail SMTP code snippets to extend your setup with just a few clicks.


Requirements: The built-in Code Snippets library requires WP Mail SMTP 4.9 or later.

Getting Started With WPCode

WP Mail SMTP code snippets are powered by WPCode, a free plugin for managing custom code. To find them, go to WP Mail SMTP » Tools and open the Code Snippets tab.

This page lists the full library of WP Mail SMTP snippets, each with a title and a short description of what it does. You can scroll through the list or use the Search Snippets box to find one quickly. Once you find the one you’d like to use, click Install Snippet.

The WP Mail SMTP Code Snippets tab showing the snippet library and the Search Snippets box

The first time you install a snippet, WP Mail SMTP prompts you to install and activate the WPCode plugin. Go ahead and click Install & Activate WPCode to add the free plugin that powers the library.

The Please Install WPCode to Use the Snippet Library prompt with the Install and Activate WPCode button

Note: For extra help, refer to WPCode’s guide on installing the WPCode plugin.

Adding WP Mail SMTP Code Snippets

Browse or search the library to find the snippet you need. Each entry shows a title and a short description, so you know exactly what the snippet does before you add it. To preview a snippet’s code first, click View.

A WP Mail SMTP snippet card with its title, description, and the Install Snippet and View buttons

When you’re ready, click the Install Snippet button for the snippet you want.

Install Snippet button

WP Mail SMTP installs it and opens the snippet in WPCode, where you’ll see the code, the insertion settings, and the conditional logic.

By default, the snippet runs everywhere on your site, so you don’t need to change the insertion settings.

The WPCode editor showing the snippet title, Code Type, and code preview

To activate the snippet, toggle the Active option on, then click Update to apply it to your site.

The WPCode editor header with the active status toggle and the Update button

Editing or Deleting a Code Snippet

Editing a Code Snippet

To change a snippet you’ve already installed, return to the Code Snippets tab and click Edit Snippet on the snippet you want to adjust.

This opens it in WPCode, where you can update the code or settings and click Update to save your changes.

The Code Snippets tab showing the Edit Snippet button on an installed snippet

Deleting a Code Snippet

To remove a snippet, go to Code Snippets » Code Snippets in your WordPress sidebar. Hover over the snippet you want to remove and click Trash.

The Code Snippets list in WPCode with the Trash option on a snippet

That’s it! Now you know how to use WP Mail SMTP code snippets to extend your setup with WPCode, all without touching your theme files.

Next, explore our code snippet tutorials for more ways to customize WP Mail SMTP.

Try our Free WP Mail SMTP plugin

Use your favorite SMTP provider to reliably send your WordPress emails.