You are currently reading the documentation for v6, while the latest version is v8.

Displaying webviews

On this page:

Whenever you send a campaign, a webview is also created. A webview is a hard to guess URL that people who didn’t subscribe can visit to read the content of your campaign.

You can get to the URL of the webview of a campaign:

$campaign->webViewUrl();

Customizing the webview

You can customize the webview. To do this, you must publish all views:

php artisan vendor:publish --provider="Spatie\Mailcoach\MailcoachServiceProvider" --tag="mailcoach-views"

After that, you can customize the webview.blade.php view in the resources/views/vendor/mailcoach/campaigndirectory.

Hiding elements from the generated webview

You can hide elements from the generated webview by wrapping them in <!-- webview:hide --> ... <!-- /webview:hide --> tags.

For example:

<html>
	<body>
		<!-- webview:hide -->
		<span>Is this email not displaying correctly? <a href="{{ webviewUrl }}">View online version</a></span>
		<!-- /webview:hide -->

		<div>
			... The rest of your email content
		</div>
		
		<!-- webview:hide -->
		<a href="{{ unsubscribeUrl }}">Unsubscribe</a>
		<!-- /webview:hide -->
	</body>
</html>

This will hide the unsubscribe and webview links from the generated webview HTML, making your email only display its essentials.