sendmail() method. When handling template files,
there are few things to take note {{ $var }} where $var is the name of injected variable.
inject()
method
setup() method, the template file also be used to configure headers. This is
useful when handling html or txt files. The @ symbol is used to process this just as displayed
below.
Sample: Template File With Headers
<setup type="config">
@site_name : {mysite}
@site_mail : {mysite@osomething.com}
@client_name: {user name}
@client_mail: {user@something.com}
@file : {[user/var/res/myfile.jpg] [myfile.php]}
@file : {[myfile/var/filename.php]}
</setup>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
setup data will be used as mail headers when
forwarding a mail. Every parameter is just as similar to the $webmail
parameters discussed in setup. However,
when handling multiple files, multiple files should be placed in their own specific angle
brackets within the curly brackets and separated only by a space just as relayed above.
It is not encouraged to do this often.
Sample: Mailer File
// ...Define some default request variables
$_GET['type'] = 'isGet';
$_POST['method'] = 'isPost';
//.. Define a global variable
$globalvar = 'Foo';
// Initialize mailer class
$mailer = new Mailer;
// Set or load the mailer configuration parameters
$mailer->server('mail.server');
$mailer->setup('mail.setup');
//Inject some local variables
$mailer->inject(['email' => 'foo@site.com']);
Load template file
$mail->sendmail('mail.template');
Sample: Template File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mail Template File</title>
</head>
<body>
Hi there, this is a message from {{$globalvar}}
This however is an injected local variable {{$email}}
The type of this message is {{get:type}}
The method of this message is {{post:method}}
Choosing any request is as easy as {{method}} or {{type}}
</body>
</html>
$name is the name of the global variable inject() method and
accessed with the similarly as the global variables. Global variables however
overides local variables. key is the post key key is the get key key will be obtained depending on the current request. However, the get
request has the higest power here. This means that if a key exists in post and equally get, then the
get request key will be picked.