Hi,
How can I send emails with custom templates ?
I created a file and named it “ChangePatientPassword.en-US.php” and placed it inside the language folder.
template file content:
Subject: Password Changed
From: <?= $From ?>
To: <?= $To ?>
Cc:
Bcc:
Format: HTML
<p>Dear Sir/Madam,</p>
<p>Your password has been changed.</p>
<p>Your new password is <?= $Password ?></p>
<p>Please feel free to contact us in case of further queries.</p>
<p>
Best Regards,<br>
Support
</p>
the error message:
C:\xampp\htdocs\telehealth\vendor\dflydev\dot-access-data\src\Data.php(132): No data exists at the given path: "EMAIL_PATIENT_CHANGE_PASSWORD_TEMPLATE"What’s wrong?
Thanks
Error Message:Fatal error: Uncaught Error: Call to a member function fetchTemplate() on null in C:\xampp\htdocs\telehealth\src\Email.php:70 Stack trace: #0 C:\xampp\htdocs\telehealth\savemyinformation.php(60): PHPMaker2024\TELEHEALTH\Email->load(‘ChangePatientPa…’, ‘’, Array) #1 {main} thrown in C:\xampp\htdocs\telehealth\src\Email.php on line 70Thanks
Error:Fatal error: Uncaught Error: Call to a member function fetchTemplate() on null in C:\xampp\htdocs\telehealth\src\Email.php:70 Stack trace: #0 C:\xampp\htdocs\telehealth\savemyinformation.php(58): PHPMaker2024\TELEHEALTH\Email->load(‘NewPatient.php’, ‘fa-IR’, Array) #1 {main} thrown in C:\xampp\htdocs\telehealth\src\Email.php on line 70What’s wrong?
Thanks
Hi,It’s the language file. I provided it for both English and Persian. I placed them inside the language folder.I tested the code in another custom file with header/footer and it works fine.
If you use your own file without using the container, some code won’t work. You may refer to the index.php of the project and copy code to create the container, e.g.
$containerBuilder = new ContainerBuilder();
$containerBuilder->addDefinitions("src/definitions.php");
$container = $containerBuilder->build();
That’s why you should avoid the old way of using standalone files, nowadays it is better to treat your application as an integrated app, not a group of standaone files. Avoid accessing standalone files by xxx.php in the URL. You may want to read Using Route_Action server event.