Template Variables Reference
Every Opterius Mail content view receives a specific set of PHP variables from its controller. This reference documents the complete variable set for each view. Variables are accessed in Blade using {{ $variable }} for escaped output or {!! $variable !!} for raw HTML (use raw output only for trusted, already-sanitised values).
Layout Variables (Available in Every Authenticated View)
These are injected by middleware and available in layouts/app.blade.php and every content view.
| Variable | Type | Description |
|---|---|---|
$folders |
array |
All IMAP folders in the user's mailbox. See structure below. |
$currentFolder |
string |
The IMAP folder name currently active, e.g. INBOX or INBOX.Sent |
$folders Item Structure
$folders[] = [
'name' => 'INBOX', // Raw IMAP folder name; use in route params
'display' => 'Inbox', // Human-readable label
'unseen' => 3, // Unread message count
'total' => 47, // Total message count
'attributes' => ['\\HasNoChildren'], // Raw IMAP attributes array
'special' => 'inbox', // 'inbox'|'sent'|'drafts'|'trash'|'spam'|null
];
inbox/index.blade.php
The folder message list view.
| Variable | Type | Description |
|---|---|---|
$messages |
array |
Paginated array of message summaries |
$total |
int |
Total messages in the current folder (for pagination display) |
$currentPage |
int |
Current pagination page number |
$perPage |
int |
Messages per page |
$error |
string|null |
IMAP connection error message, or null if no error |
$messages Item Structure
$messages[] = [
'uid' => 1042, // IMAP UID (stable message identifier)
'seq' => 5, // IMAP sequence number (volatile)
'flags' => ['\\Seen', '\\Flagged'],// IMAP flags array
'seen' => true, // Shorthand: message has been read
'flagged' => false, // Shorthand: message is starred/flagged
'from' => [
'name' => 'Alice Smith', // Sender display name (may be empty string)
'email' => 'alice@example.com', // Sender email address
],
'subject' => 'Project update', // Decoded subject line
'date' => Carbon instance, // Raw Carbon date object
'date_formatted' => 'Apr 12, 14:23', // Pre-formatted date string
'preview' => 'Hi team, just wanted…',// Plain-text preview snippet (~100 chars)
];
Usage example:
@foreach ($messages as $message)
<div class="{{ $message['seen'] ? '' : 'font-bold' }}">
<a href="{{ route('inbox.message', ['folder' => $currentFolder, 'uid' => $message['uid']]) }}">
{{ $message['from']['name'] ?: $message['from']['email'] }}
— {{ $message['subject'] }}
</a>
<span>{{ $message['date_formatted'] }}</span>
</div>
@endforeach
inbox/message.blade.php
The single message read view.
| Variable | Type | Description |
|---|---|---|
$message |
array |
Full message data |
$message Structure
$message = [
'uid' => 1042,
'folder' => 'INBOX',
'from' => ['name' => 'Alice Smith', 'email' => 'alice@example.com'],
'to' => [['name' => 'Bob', 'email' => 'bob@example.com']], // array of recipients
'cc' => [], // array, may be empty
'reply_to' => ['name' => '', 'email' => 'alice@example.com'],
'subject' => 'Project update',
'date' => Carbon instance,
'date_formatted' => 'Saturday, April 12 2026 at 14:23',
'body_html' => '<p>Hi team...</p>', // Sanitised HTML body; render with {!! !!}
'body_text' => 'Hi team...', // Plain text body
'has_attachments'=> true,
'attachments' => [
[
'filename' => 'report.pdf',
'mime_type' => 'application/pdf',
'size_bytes' => 204800,
'download_url' => '/inbox/1042/attachment/0',
],
],
'flags' => ['\\Seen'],
'raw_headers' => '...', // Full RFC 2822 header block
];
Rendering the HTML body safely:
{{-- body_html is already sanitised by HtmlPurifier before being passed to the view --}}
<iframe id="message-body" srcdoc="{!! htmlspecialchars($message['body_html']) !!}"
class="w-full border-0" style="min-height:400px"></iframe>
compose/index.blade.php
The compose / reply / forward view.
| Variable | Type | Description |
|---|---|---|
$mode |
string |
'compose', 'reply', 'reply-all', or 'forward' |
$to |
string |
Pre-populated To address (empty for compose) |
$cc |
string |
Pre-populated CC addresses |
$subject |
string |
Pre-populated subject (includes Re:/Fwd: prefix) |
$body |
string |
Pre-populated body HTML (quoted original message for reply/forward) |
$fromEmail |
string |
Authenticated user's email address |
$fromName |
string |
Authenticated user's display name |
$originalFolder |
string|null |
Folder of the message being replied to/forwarded |
$originalUid |
int|null |
UID of the message being replied to/forwarded |
contacts/index.blade.php
| Variable | Type | Description |
|---|---|---|
$contacts |
array |
All contacts for the authenticated user |
$contacts Item Structure
$contacts[] = [
'id' => 12,
'name' => 'Alice Smith',
'email' => 'alice@example.com',
'phone' => '+1 555 0100',
'notes' => 'Met at conference 2025',
];
contacts/show.blade.php
| Variable | Type | Description |
|---|---|---|
$contact |
array |
Single contact, same structure as above |
search/index.blade.php
| Variable | Type | Description |
|---|---|---|
$query |
string |
The search string entered by the user |
$results |
array |
Array of matching messages, same structure as $messages in inbox |
$total |
int |
Total result count |
settings/index.blade.php
| Variable | Type | Description |
|---|---|---|
$settings |
array |
User's current settings values |
$settings Keys
$settings = [
'display_name' => 'Bob Jones',
'timezone' => 'America/New_York',
'messages_per_page' => 25,
'html_emails' => true, // Prefer HTML rendering
'reply_position' => 'top', // 'top' or 'bottom'
'signature' => '<p>Bob Jones<br>example.com</p>',
'two_factor_enabled' => false,
'theme' => 'system', // 'light', 'dark', 'system'
];
Plugin-injected settings sections are rendered automatically via the HOOK_SETTINGS plugin hook and do not need to be added manually to the settings view.