If I don't recall wrong, you need to declare those variables as public in your class..
public param;
public month;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using Laravel 5.3 to create a email template feature.
It prompts Undefined variable: month (View: D:\Workspace\XAMPP\htdocs\webminder\resources\views\email\view.blade.php) whenever I enter the URL, http://www.webminder.com/send-reminder/ Do take note this is virtual environment
It shows result when I tried dd($month);
"December"
I cannot figure out what is the issue behind the scene.
Although it shows error whenever I run the URL. But the email still manage to send out to Mailtrap.
app\Mail\RenewalReminder.php
public function __construct($param, $todayMonth)
{
$this->param = $param;
$this->month = $todayMonth;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$address = '[email protected]';
$name = 'Wiz Werx - Renewal Reminder';
$subject = 'Renewal Reminder';
return $this->view('email.view')
->with(['reminders' => $this->param, 'month' => $this->month])
->from($address, $name)
->replyto($address, $name)
->subject($subject);
}
email\view.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reminder Renewal</title>
</head>
<body>
<table>
<tr>
<td class="bg-letterhead" colspan="3">
<img src="demo.jpg" class="img-responsive" alt="Letterhead" />
<h1>Server Expiry List - {{ $month }}</h1>
</td>
</tr>
<tr>
<th>
Web Hosting Server
</th>
<th>
Hosting Provider
</th>
<th>
Expiry Date
</th>
</tr>
@foreach ($reminders as $reminder)
<tr>
<td>
{{ $reminder['server_name'] }}
</td>
<td>
{{ $reminder['service_provider'] }}
</td>
<td>
{{ $reminder['expiry_date'] }}
</td>
</tr>
@endforeach
</table>
</body>
</html>
@Tyris You need to pass the todayMonth variable to your email.view view like:
return view('email.view', ['month' => $todayMonth]);
Please or to participate in this conversation.