_priority = $priority; } } /** * Set the name and email address for the FROM field. * * @param string Email address to set for FROM field. * @param string Name to set for FROM field. * @return boolean True on success. * @since 2.0 * * @throws JException */ public function setFrom($address, $name = '') { // Sanitize the address and name. $address = trim(preg_replace('/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i', '', $address)); $name = trim(preg_replace('/(%0A|%0D|\n+|\r+)/', '', $name)); // Validate the FROM email address. if (filter_var($address, FILTER_VALIDATE_EMAIL) === false) { throw new JException('Invalid email address: '.$address.'.', 0, E_WARNING); return false; } // Set the FROM address and name. $this->_fromAddress = $address; $this->_fromName = $name; return true; } /** * Set the mail subject, sanitizing and securing it against injection attacks. * * @param string Mail subject. * @return void * @since 2.0 */ public function setSubject($text = '') { $this->_subject = trim(preg_replace('/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i', '', $text)); } /** * Set the mail HTML body. Making modifications for inline images and backgrounds * as necessary and also populating the text body if not already populated. * * @param string HTML body text. * @return void * @since 2.0 */ public function setBodyHTML($body, $base = '') { // Sanitize the input. $body = trim(preg_replace('/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i', '', $body)); // If the text body is empty attempt to populate it from the HTML body. if (empty($this->_body_text)) { if($text = html_entity_decode(trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/is', '', $body))))) { $this->_body_text = $text; } else { $this->_body_text = "This message requires an HTML capable client to be read.\n\n"; } } // Set the mail mime type and body HTML. $this->_mime = 'text/html'; $this->_body_html = $body; } /** * Set the mail text body. * * @param string Body text. * @return void * @since 2.0 */ public function setBodyText($body) { $this->_body_text = trim(preg_replace('/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i', '', $body)); } }