Title: SMTP for Contact Form 7
Author: Erik
Published: <strong>20. november, 2022</strong>
Last modified: 24. marts, 2026

---

Søg plugins

![](https://ps.w.org/cf7-smtp/assets/icon.svg?rev=2821098)

# SMTP for Contact Form 7

 Af [Erik](https://profiles.wordpress.org/codekraft/)

[Download](https://downloads.wordpress.org/plugin/cf7-smtp.1.1.0.zip)

 * [Detaljer](https://da.wordpress.org/plugins/cf7-smtp/#description)
 * [Vurderinger](https://da.wordpress.org/plugins/cf7-smtp/#reviews)
 *  [Installation](https://da.wordpress.org/plugins/cf7-smtp/#installation)
 * [Udvikling](https://da.wordpress.org/plugins/cf7-smtp/#developers)

 [Support](https://wordpress.org/support/plugin/cf7-smtp/)

## Beskrivelse

WordPress uses PHPMailer to send mail from with your local mail server, but it can
happen that your mail were not accepted by mail providers…
 This can happen for 
several reasons, sometimes because the mail server is not configured or sometimes
because the records DKIM, DMARC and SPF of the domain been set up correctly and 
so on… Anyway you can avoid any problems by using an external SMTP server and sending
mail with it!

#### Additional features

✅ **OAuth2 Authentication:** Securely connect to Gmail and Microsoft Office 365
without needing to store passwords in your database or enable “less secure apps”.

✅ **Per-Form Custom Templates:** Wrap CF7 emails with beautiful templates. You 
can now select a specific custom template for _each_ form directly from the plugin
settings! ✅ **Global or CF7-Only Mode:** Choose whether to override all WordPress
emails with this SMTP configuration or limit it exclusively to Contact Form 7 submissions.
✅ **Live testing:** a module for testing e-mail settings with the Rest-Api (that
avoid to reload the page for this kind of test). The entire output of the php mailer
will be captured, which will be useful in case of configuration errors or to get
the wrong parameter when is possible. ✅ **Automated Reports:** choose when and 
what email you want to receive the report and I will send you a beautifully formatted
HTML summary of sent and failed emails. Includes log retention settings to keep 
your database clean. ✅ **Advanced Headers & Security:** Easily automatically set“
Reply-To” headers, allow insecure options for self-signed certificates, and define
custom “From Name” and “From Email” settings.

This plugin is ads free and I don’t want to try to sell you any pro version!
 If
you want to contribute, there are many ways to do so, from simple suggestions and
bug reports to translating and contributing code. See below how to do it!

### SMTP

SMTP stands for ‘Simple Mail Transfer Protocol’.
 It is a connection-oriented, text-
based network protocol of the Internet protocol family and as such is on the seventh
layer of the ISO/OSI model, the application layer. Like any other network protocol,
it contains the rules for proper communication between networked computers. SMTP
is specifically responsible for sending and forwarding e-mails from a sender to 
a recipient. Since its release in 1982 as the successor to the ‘Mail Box Protocol’
in Arpanet, SMTP has become the standard protocol for sending e-mails. However, 
the SMTP procedure remains largely invisible to the normal consumer, as it is executed
in the background by the e-mail programme used. Only if the software, the webmail
application on the browser or the mobile e-mail application does not automatically
determine the SMTP protocol when creating an account, does it have to be set manually
to ensure smooth e-mail traffic.

#### SMTP presets

 1. Aruba
 2. Gmail (tls and ssl)
 3. Yahoo (tls and ssl)
 4. Outlook (tls and ssl)
 5. Office365 (tls)

#### OAuth2 Setup

**Google Gmail**
 To use Gmail with OAuth2, you need to create a Google Cloud Project:
1. Go to **Google Cloud Console** (console.cloud.google.com). 2. Create a new project.
3. Go to **APIs & Services > Credentials** and click **Create Credentials > OAuth
client ID**. 4. Application type: **Web application**. 5. **Authorized redirect 
URIs**: Copy the URL from the plugin settings (e.g., `https://your-site.com/wp-admin/
admin.php?page=cf7-smtp&oauth2_callback=1`). 6. Copy the **Client ID** and **Client
Secret** into the plugin settings. 7. Important: Go to **OAuth consent screen > 
Test users** and add your email address if the app is in “Testing” mode. 8. Click**
Connect with OAuth2** in the plugin settings.

**Microsoft Office 365**
 1. Go to the **Azure Portal** (portal.azure.com). 2. Navigate
to **Azure Active Directory > App registrations > New registration**. 3. Enter an
application name and set the **Redirect URI** (Web) to the exact URL provided in
the plugin settings. 4. Go to **Certificates & secrets** and create a new client
secret. Copy the secret’s Value. 5. Go to **API permissions > Add a permission >
Microsoft Graph > Delegated permissions** and add `SMTP.Send` and `offline_access`.
6. Copy the **Application (client) ID** and the **Client Secret** into the plugin
settings. 7. Click **Connect with OAuth2**.

Would you like to find more presets (that you think are useful to other users)?

Open a request in the support form and provide the necessary connection data (auth,
server address and port). In the next cf7-smtp version you will find the required
configuration among the presets.

#### Security

It’s warmly advised to use OAuth2 for supported providers (Gmail, Office365) so 
no passwords are saved. If using basic SMTP authentication, it is highly recommended
to store at least the password into wp-config.php as a constant.
 And in addition,
it’s also very easy! It needs only to add

    ```
    define( 'CF7_SMTP_USER_PASS', 'mySecr3tp4ssWord' );
    ```

into your `wp-config.php` just before

    ```
    /* That's all, stop editing! Happy publishing. */
    ```

All passwords will be stored encrypted, but still it is not good practice to put
it into database!

#### Quick setup

as with the user password other constants can also be defined.
 Available constant
are CF7_SMTP_HOST, CF7_SMTP_PORT, CF7_SMTP_AUTH, CF7_SMTP_USER_NAME, CF7_SMTP_USER_PASS,
CF7_SMTP_FROM_MAIL, CF7_SMTP_FROM_NAME

But, to quickly set up the plugin there is one constant that wraps all the others,
so in case you manage multiple websites this will be very convenient!

    ```
    define(
        'CF7_SMTP_SETTINGS',
        array(
          'host'      => string,
          'port'      => number,
          'auth'      => ''|'tls'|'ssl',
          'user_name' => string,
          'user_pass' => string,
          'replyTo'   => true|false,
          'insecure'  => true|false,
          'from_mail' => email,
          'from_name' => string,
          'smtp_mode' => 'cf7'|'override',
      ));
    ```

#### Template

Wouldn’t it be better to have a small container to make our mail a little prettier?

Well we have it! You can now assign specific templates to each of your forms via
the plugin settings dashboard. To use your own custom templates for emails, simply
create them by following these steps: 1. Create a folder named `cf7-smtp/` or `templates/
cf7-smtp/` in your theme (or child theme) folder. 2. Create a `.php` or `.html` 
template file inside it. 3. Go to the plugin settings under **Style > Form Email
Templates**, and select your newly found custom template from the dropdown menu 
for the desired form. 4. (Optional) You can customize the logo, website link, and
other template parts. Checkout the filter documentation on GitHub/wiki.

### Support

Community support: via the [support forums](https://wordpress.org/support/plugin/cf7-smtp/)
on wordpress.org
 Bug reporting (preferred): file an issue on [GitHub](https://github.com/erikyo/cf7-smtp)

#### Contribute

We love your input!
 We want to make contributing to this project as easy and transparent
as possible, whether it’s:

 * Reporting a bug
 * Testing the plugin
 * Discussing the current state, features, improvements
 * Submitting a fix or a new feature

We use GitHub to host code, to track issues and feature requests, as well as accept
pull requests.
 By contributing, you agree that your contributions will be licensed
under its GPLv2 License.

## Skærmbilleder

 * [[
 * Plugin options (1/1)

## Installation

#### Using The WordPress Dashboard

 1. Navigate to the ‘Add New’ in the plugins dashboard
 2. Search for ‘cf7-smtp’
 3. Click ‘Install Now’
 4. Activate the plugin on the Plugin dashboard

#### Uploading in WordPress Dashboard

 1. Navigate to the ‘Add New’ in the plugins dashboard
 2. Navigate to the ‘Upload’ area
 3. Select `cf7-smtp.zip` from your computer
 4. Click ‘Install Now’
 5. Activate the plugin in the Plugin dashboard

#### Using FTP

 1. Download `cf7-smtp.zip`
 2. Extract the `cf7-smtp` directory to your computer
 3. Upload the `cf7-smtp` directory to the `/wp-content/plugins/` directory
 4. Activate the plugin in the Plugin dashboard

## Anmeldelser

![](https://secure.gravatar.com/avatar/efdf0291b8c9bff0d2b1833446dedb1ad48198f9c3f82294e32f5ff617e972e3?
s=60&d=retro&r=g)

### 󠀁[Solved my SMTP problem](https://wordpress.org/support/topic/solved-my-smtp-problem/)󠁿

 [Wendihihihi](https://profiles.wordpress.org/wendihihihi/) 29. januar, 2024

Works for me. Message didn’t get lost anymore.

![](https://secure.gravatar.com/avatar/df1ba720f6e843673feb77d7ea1ee30e08c66d15783178edb78a2efb856c4567?
s=60&d=retro&r=g)

### 󠀁[Doest work](https://wordpress.org/support/topic/doest-work-9/)󠁿

 [bbbirkan](https://profiles.wordpress.org/bbbirkan/) 16. oktober, 2023 1 svar

i know all my setup correct but doest work this plugin

 [ Læs alle 2 anmeldelser ](https://wordpress.org/support/plugin/cf7-smtp/reviews/)

## Bidragsydere & udviklere

“SMTP for Contact Form 7” er open source-software. Følgende personer har bidraget
til dette plugin.

Bidragsydere

 *   [ Erik ](https://profiles.wordpress.org/codekraft/)
 *   [ gardenboi ](https://profiles.wordpress.org/gardenboi/)

[Oversæt “SMTP for Contact Form 7” til dit eget sprog.](https://translate.wordpress.org/projects/wp-plugins/cf7-smtp)

### Interesseret i udvikling?

[Gennemse koden](https://plugins.trac.wordpress.org/browser/cf7-smtp/), tjek [SVN repository](https://plugins.svn.wordpress.org/cf7-smtp/),
eller abonner på [udviklerloggen](https://plugins.trac.wordpress.org/log/cf7-smtp/)
via [RSS](https://plugins.trac.wordpress.org/log/cf7-smtp/?limit=100&mode=stop_on_copy&format=rss).

## Ændringslog

#### 1.1.0

 * **New:** Added OAuth2 authentication support for Microsoft Office 365.
 * **New:** Per-form template selection! You can now assign specific custom templates
   to individual Contact Form 7 forms from the settings.
 * **New:** Custom templates are now supported inside your theme or child-theme 
   folder (`your-theme/cf7-smtp/`).
 * **New:** SMTP Mode selection – choose whether to override all WordPress emails
   or just CF7.
 * **Enhancement:** Revamped automated reports with a beautiful HTML template.
 * **Enhancement:** Added log retention day settings and manual flush logs capability.
 * thanks to @islp for reporting the issues related to “from” field and dashboard
   widget visibility

#### 1.0.0

 * Cleaner code, updated dependencies
 * @DAnn2012 has contributed fixin a bug in a translation string

#### 0.0.2

 * The configuration panel has been integrated with Contact Form 7 forms
 * The widget which shows sent and unsent emails is now in the WordPress dashboard
 * Fix an issue about password being reset when saving the plugin options

#### 0.0.1

 * First Release

## Meta

 *  Version **1.1.0**
 *  Senest opdateret **2 uger siden**
 *  Aktive installationer **1.000+**
 *  WordPress-version ** 5.5 eller højere **
 *  Testet op til **6.9.4**
 *  PHP-version ** 7.1 eller højere **
 *  Sprog
 * [English (US)](https://wordpress.org/plugins/cf7-smtp/)
 * Tags
 * [contact form 7](https://da.wordpress.org/plugins/tags/contact-form-7/)[mail](https://da.wordpress.org/plugins/tags/mail/)
   [oauth2](https://da.wordpress.org/plugins/tags/oauth2/)[smtp](https://da.wordpress.org/plugins/tags/smtp/)
   [wp-mail](https://da.wordpress.org/plugins/tags/wp-mail/)
 *  [Avanceret visning](https://da.wordpress.org/plugins/cf7-smtp/advanced/)

## Bedømmelser

 4 ud af 5 stjerner.

 *  [  1 5-stjernet anmeldelse     ](https://wordpress.org/support/plugin/cf7-smtp/reviews/?filter=5)
 *  [  0 4-stjernet anmeldelser     ](https://wordpress.org/support/plugin/cf7-smtp/reviews/?filter=4)
 *  [  1 3-stjernet anmeldelse     ](https://wordpress.org/support/plugin/cf7-smtp/reviews/?filter=3)
 *  [  0 2-stjernet anmeldelser     ](https://wordpress.org/support/plugin/cf7-smtp/reviews/?filter=2)
 *  [  0 1-stjernet anmeldelser     ](https://wordpress.org/support/plugin/cf7-smtp/reviews/?filter=1)

[Tilføj min vurdering](https://wordpress.org/support/plugin/cf7-smtp/reviews/#new-post)

[Se alle anmeldelser.](https://wordpress.org/support/plugin/cf7-smtp/reviews/)

## Bidragsydere

 *   [ Erik ](https://profiles.wordpress.org/codekraft/)
 *   [ gardenboi ](https://profiles.wordpress.org/gardenboi/)

## Support

Problemerne er løst inden for de sidste to måneder:

     1 ud af 2

 [Vis supportforum](https://wordpress.org/support/plugin/cf7-smtp/)