Using functions in e-mail templates
The template system includes options to override the subject, add/remove addressees, create file attachements and to apply formatting using html tags and cascading style sheets (CSS). The e-mail template system includes options to call functions that perform specific tasks.
An e-mail template in Notepad++
The following functions are available for all e-mail templates:
- setSubject: This function sets the subject for the e-mail message. If no subject is specified the subject is set to: No Subject.
$this->setSubject("Password Assistance")
- setFrom: This function overrides the Sender e-mail address set in the E-mail Settings.
$this->setFrom("info@printshopweb.com")
- setFromName: This function overrides the Sender e-mail address set in the E-mail Settings.
$this->setFromName("MyCards.com")
- setTo: By default PrintShop Mail Web will determine the recipients of the message based on the E-mail Addressees settings in the Settings section. The setTo function overrides the "To" header defined by the system.
The first parameter is the e-mail address, the function accepts a second optional parameter that is used as a human-readable name of the recipient for the header.
$this->setTo(“psw-beta@eu.objectiflune.com”,”PSW Beta”)
- addTo: Adds a recipient to the mail with a "To" header.
The first parameter is the e-mail address, the function accepts a second optional parameter that is used as a human-readable name of the recipient for the header.
$this->addTo(“psw-beta@eu.objectiflune.com”,”PSW Beta”)
- addCc: Adds a recipient to the "Cc" header of the message.
The first parameter is the e-mail address, the function accepts a second optional parameter that is used as a human-readable name of the recipient for the header.
$this->addCc(“psw-beta@eu.objectiflune.com”,”PSW Beta”)
- addBcc: Adds a recipient to the "BCc" header of the message.
The first parameter is the e-mail address, the function accepts a second optional parameter that is used as a human-readable name of the recipient for the header.
$this->addBcc(“logger@eu.objectiflune.com”,”Logger”)
- setHtmlContent: Sets the content type of the message body to text/html (default).
$this->setHtmlContent()
- setPlainTextContent: Sets the content type of the message body to text/plain.
$this->setPlainTextContent()
- setCharset: This functions sets the charset of the message body.
$this->setCharset("UTF-8"); (default)
$this->setCharset("iso-8859-1")
- addAttachment: Adds an attachment from a path on the filesystem.
$this->addAttachment("application/pdf","sample1.pdf");
$this->addAttachment("application/pdf","/files/jobs/1/8/8_lr.pdf");
$this->addAttachment("application/pdf","/files/jobs/$this->companyid/$this->jobs[0]/$this-> jobs [0] _lr.pdf");
//Attach the softproof pdf of each document/job to the message:
foreach ($this->jobs as $key => $job) {
$id = $job[id];
$this->addAttachment("application/pdf","/files/jobs/$this->companyid/” . $id . “/” . $id . “_lr.pdf");
}
- getString: Returns the given string from the language strings.
$this->getString(cNo);
$this->setSubject("$this->getString(cYourAccountDetails)")
- replaceString: Replaces the value of a string based on a match in the second parameter (array). The result is returned.
$this->replaceString($this->rush, array(0=>$this->getString(cNo), 1=>$this->getString(cYes))
- skipEmpty: Use this function to skip a specific value in case it is empty. The second parameter is optional and defines the string that will be inserted when the input string is not empty. If this parameter is omitted the input string will be returned.
<?php echo $this->skipEmpty($this->shippingaddress2,$this->shippingaddress2 . "<br />"); ?>
<?php echo $this->skipEmpty($this->shippingaddress2); ?>.