Skip to content
Koen edited this page Nov 2, 2015 · 1 revision

Mails

Hang on. Before you start reading this part, grab a drink, take a toilet-stop and brush your teeth, because this is a big part. First of all, create an mail-object (set archived to false if you don't want to save emails in an archive(application/logs)):

$mail = new Mail($archived = true);

Now that you have a mail-object, you can add a template (find them in system/layout/mail), or write your entire body yourself. If you want to use a template, do this immediately after creating the object. Later on it'll be too late!

Functions

! All chain-able, call functions one after the other, like this: $mail->setSubject('subject')->addTo('[email protected]', 'Jimmy')->send();)

Create the mail
public function setSubject($subject);
/**
* Set the subject of the mail
*
* @param 	String $subject: Subject to be set
* @return Object $mail
*/
public function setHeaders($headers);
/**
* Set the headers of the mail
*
* @param 	Array $headers: Headers for the mail. Use with care
* @return Object $mail
*/
public function addTo($toEmail, $toName = "");
/**
* Add a recipient for the mail
*
* @param 	String $toEmail: E-mailaddress of the recipient
* @param 	String $toName: Name of the recipient (optional)
* @return Object $mail
*/
public function addCc($ccEmail, $ccName = "");
/**
* Add a recipient as CC for the mail
*
* @param 	String $ccEmail: E-mailaddress of the recipient
* @param 	String $ccName: Name of the recipient (optional)
* @return Object $mail
*/
public function addBcc($bccEmail, $bccName = "");
/**
* Add a recipient as BCC for the mail
*
* @param 	String $bccEmail: E-mailaddress of the recipient
* @param 	String $bccName: Name of the recipient (optional)
* @return Object $mail
*/
public function setFrom($fromEmail, $fromName = "");
/**
* Set the sender e-mailaddress (Default: TITLE_bot@BASE_URL.com)
*
* @param 	String $fromEmail: E-mailaddress of the sender
* @param 	String $fromName: Name of the sender (optional)
* @return Object $mail
*/
public function setBody($body, $type = "HTML");
/**
* Set the body of the mail
*
* @param 	String $body: Body of the mail (plain or HTML)
* @param 	String $type: Type of the body ("plain" or "html")
* @return Object $mail
*/
public function setImportance($flag);
/**
* Set the importance of the mail
*
* @param 	Boolean $flag: Whether the mail is urgent or not
* @return Object $mail
*/
public function setTemplate($template);
/**
* Set the template of the mail (call as early as possible!)
*
* @param 	String $template: Any template from system/layout/mail (create your own if needed)
* @return Object $mail
*/
public function addContent($key, $value);
/**
* Add content to the mail, or replace keys in a template
*
* @param 	String $key: String to replace
* @param 	String $value: String to replace with
* @return Object $mail
*/
public function send();
/**
* Send the mail via Mandrillapp
*
* @return Array $results
*/
Clear fields
public function clearSubject();
/**
* Clear the subject
*
* @return Object $mail
*/
public function clearHeaders();
/**
* Clear the headers
*
* @return Object $mail
*/
public function clearBody();
/**
* Clear the body
*
* @return Object $mail
*/
public function clearFrom();
/**
* Clear the sender
*
* @return Object $mail
*/
public function clearRecipients();
/**
* Clear the recipients
*
* @return Object $mail
*/
Clone this wiki locally