
Optional Contact Form 7 fields can leave a notification full of labels with no answers: Company, Website, Reference. The Mail tab includes an option to exclude lines with blank mail-tags. Used carefully, it makes an inquiry easier to read. Used without reviewing the template’s line structure, it can leave confusing headings or unexpectedly remove useful surrounding text.
This guide explains a plain-text setup first, then the extra review needed for HTML email. It concerns notification output, not whether a field is required or whether a submission is saved. Keep those decisions separate so a cleaner message does not hide a missing-data problem.
Inventory the optional answers
Open the form definition and the receiving notification side by side. List each field name, its required or optional status, and the corresponding mail-tag. For example, an optional field named company maps to [company] in the message. A required reply address should retain its own clear line so the receiving team can act on the inquiry.
Ask why each optional answer is collected. If a company name changes routing, an empty company should have an agreed meaning. If it adds no practical context, removing it from the form may be better than collecting and hiding it. Excluding a notification line should be a presentation choice after the data contract is clear.
Enable the option in the intended Mail template
CF7 documents the checkbox in Setting up mail. Select Exclude lines with blank mail-tags from output in the template you want to change. If Mail (2) is active, review it independently. A short visitor acknowledgement and a detailed team notification do not necessarily need the same layout.
Begin with one optional mail-tag per source line. This makes the behavior easier to predict and maintain:
Name: [your-name]
Reply address: [your-email]
Company: [company]
Website: [website]
Message:
[your-message]
When company is empty and website is supplied, the useful expectation is a notification without the Company line and with the Website line intact. Verify that expectation in your installed version and template. Do not describe the checkbox as deleting the field’s saved record or changing what a connector receives.
Understand the source-line boundary
The current CF7 source processes mail-template text by newline. Its exclusion logic removes a line when replaced mail-tags exist on that line and all their values are empty. If at least one replaced value has content, the line remains. A line without replaced tags is retained.
That distinction matters when a template combines optional answers. With Company: [company] | Website: [website], supplying only a website can preserve the line with a blank company label. Split independently optional details onto their own lines if you want each missing answer omitted separately. Avoid relying on a broad description that says every line containing any empty tag always disappears.
A heading placed on its own line can also remain after the answer beneath it disappears. Keep an optional label and its answer together. For multiline messages, preserve a clear structure and inspect the resulting line breaks instead of assuming the option understands paragraphs as a human reader would.
Do not confuse an empty answer with a default
A field initialized with a literal value is not blank merely because the visitor did not edit it. If an optional company field starts with “Not supplied,” that text is an answer for formatting purposes. A placeholder, by contrast, is only a hint while the input is empty. Our prefill guide explains the difference.
Review fallback text before enabling exclusion. A default such as General inquiry can be useful for routing, but it should not be mistaken for an affirmative choice. Keep reporting categories aligned with the meaning of the submitted value. Do not infer that every retained notification line represents deliberate visitor input.
Treat HTML formatting as a separate review
In HTML email, source newlines and visible rows are different things. Putting a whole table on one source line makes its optional cells share the same line-based processing boundary. The option is not a general engine for removing an HTML row, a conditional section or all surrounding markup associated with a field.
Use a simple layout where complete optional units are understandable in the source. Inspect the final HTML after tag replacement and check it in the controlled receiving mailbox. A visually empty table cell can remain even when a field is blank, while removing a line with opening or closing markup can damage the structure. For complex conditional sections, ask a maintainer to design explicit behavior rather than depending on accidental line breaks.
Our HTML notification guide covers the wider formatting workflow. Start there if the email is already difficult to read before optional values are considered.
Run a small output matrix
- Supply every optional value and confirm nothing useful disappears.
- Leave each optional field empty one at a time.
- Leave all optional fields empty and inspect headings and spacing.
- Use a multiline message and check the full text remains readable.
- Review Mail (2) separately if it uses the same field names.
Use synthetic details in authorized staging with a controlled destination. Save a before-and-after example showing exactly what changed. If a value is missing even when supplied, compare the field name and mail-tag before investigating email delivery. If the message body is right but the destination record differs, inspect that connector’s mapping independently.
Keep reporting independent from cosmetic cleanup
A cleaner email does not prove a higher conversion rate or better lead quality. Define those outcomes in the destination workflow. Svetlik Analytics for Contact Form 7, our free plugin, provides submission trends and statistics; it does not audit your notification’s conditional formatting.
Add the output cases to your regular form checklist. Preserve the previous template for a focused rollback, then repeat the checks after renaming fields or adding optional details. The goal is a message that retains every useful answer and omits genuinely empty decoration.
Sources
Official references checked October 15, 2026: CF7 mail settings, current line-processing implementation, and form-tag and mail-tag syntax. Implementation details should be rechecked when upgrading CF7.
