Template emails
A mail is a PAD template, rendered to an HTML part and a text part and handed to a transport. Templates live in _mail/, looked up like _include/: _mail/welcome.pad is the HTML part, _mail/welcome.txt the text part - without one, the text is made from the HTML - and _mail/welcome.php runs first. _inits.pad and _exits.pad in the same _mail/ are the email's layout, with @page@ where the mail goes:
|
PHP fragments/mail_1.php |
HTML fragments/mail_1.pad |
Result |
|---|---|---|
|
|
To ann@example.com: Welcome to the shop Welcome, Ann! Your account is ready: sign in (https://example.com/account). -- The shop |
From a template, {mail} sends the same way. With a template it is {mail to=$email, template='welcome', subject='Welcome'}; as a pair, the content is the HTML part, rendered where it stands - in a loop with the fields of the row:
|
PHP fragments/mail_2.php |
HTML fragments/mail_2.pad |
Result |
|---|---|---|
|
|
Sent: Your order |
-
from,cc,bccandreplyToset the other headers; an address isann@example.comorAnn <ann@example.com>, several separated by commas. A line break in any of them is refused. -
$padMailTransportsays where it goes.'file', the default, writes every message as an.emlunderDATA/mail/instead of sending it, keeping the newest$padMailKeep;'mail'sends through PHP'smail(); the name of a function of the application gets the message - the place for SMTP through a library. -
$padMailFromis the sender;$padMailLastthe last message of the request.