<commit_before><?php
namespace wcf\system\mail;
use wcf\data\language\Language;
use wcf\system\WCF;
use wcf\util\FileUtil;
use wcf\util\StringUtil;

/**
 * This class represents an e-mail.
 * 
 * @author	<NAME>
 * @copyright	2001-2013 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	data.mail
 * @category	Community Framework
 */
class Mail {
	/**
	 * line ending string
	 * @var string
	 */
	public static $lineEnding = "\n";
	
	/**
	 * mail header
	 * @var string
	 */
	protected $header = '';
	
	/**
	 * boundary for multipart/mixed mail
	 * @var string
	 */
	protected $boundary = '';
	
	/**
	 * mail content mime type
	 * @var string
	 */
	protected $contentType = "text/plain";
	
	/**
	 * mail recipients
	 * @var array<string>
	 */
	protected $to = array();
	
	/**
	 * mail subject
	 * @var string
	 */
	protected $subject = '';
	
	/**
	 * mail message
	 * @var string
	 */
	protected $message = '';
	
	/**
	 * mail sender
	 * @var array<string>
	 */
	protected $from = array();
	
	/**
	 * mail carbon copy
	 * @var array<string>
	 */
	protected $cc = array();
	
	/**
	 * mail blind carbon copy
	 * @var array<string>
	 */
	protected $bcc = array();
	
	/**
	 * mail attachments
	 * @var array
	 */
	protected $attachments = array();
	
	/**
	 * priority of the mail
	 * @var	integer
	 */
	protected $priority = 3;
	
	/**
	 * mail body
	 * @var	string
	 */
	protected $body = '';
	
	/**
	 * mail language
	 * @var wcf\data\language\Language
	 */
	protected $language = null;
	
	/**
	 * Creates a new Mail object.
	 * 
	 * @param	string		$to
	 * @param	string		$subject
	 * @param	string		$message
	 * @param	string		$from
	 * @param	string		$cc
	 * @param	string		$bcc
	 * @param	array		$attachments
	 * @param	integer		$priority
	 * @param	string		$header
	 */
	public function __construct($to = '', $subject = '', $message = '', $from = '', $cc = '', $bcc = '', $attachments = array(), $priority = '', $header = '') {
		$this->setBoundary();
		
		if (empty($from)) $from = array(MAIL_FROM_NAME => MAIL_FROM_ADDRESS);
		if (empty($priority)) $priority = 3;
		
		$this->setFrom($from);
		$this->setSubject($subject);
		$this->setMessage($message);
		$this->setPriority($priority);
		$this->setHeader($header);
		
		if (!empty($to)) $this->addTo($to);
		if (!empty($cc)) $this->addCC($cc);
		if (!empty($bcc)) $this->addBCC($bcc);
		
		if (!empty($attachments)) $this->setAttachments($attachments);
	}
	
	/**
	 * Creates and returns a basic header for the email.
	 * 
	 * @return	string		mail header
	 */
	public function getHeader() {
		if (!empty($this->header)) {
			$this->header = preg_replace('%(\r\n|\r|\n)%', self::$lineEnding, $this->header);
		}
		
		$this->header .=
			'X-Priority: 3'.self::$lineEnding
			.'X-Mailer: WoltLab Community Framework Mail Package'.self::$lineEnding									
			.'MIME-Version: 1.0'.self::$lineEnding
			.'From: '.$this->getFrom().self::$lineEnding
			.($this->getCCString() != '' ? 'CC:'.$this->getCCString().self::$lineEnding : '')
			.($this->getBCCString() != '' ? 'BCC:'.$this->getBCCString().self::$lineEnding : '');
			
		if (count($this->getAttachments())) {
			$this->header .= 'Content-Transfer-Encoding: 8bit'.self::$lineEnding;
			$this->header .= 'Content-Type: multipart/mixed;'.self::$lineEnding;
			$this->header .= "\tboundary=".'"'.$this->getBoundary().'";'.self::$lineEnding;
		}
		else {
			$this->header .= 'Content-Transfer-Encoding: 8bit'.self::$lineEnding;
			$this->header .= 'Content-Type: '.$this->getContentType().'; charset=UTF-8'.self::$lineEnding;
		}
		
		return $this->header;
	}
	
	/**
	 * Creates and returned the recipients list (TO, CC, BCC).
	 * 
	 * @param	boolean		$withTo
	 * @return	string
	 */
	public function getRecipients($withTo = false) {
		$recipients = '';
		if ($withTo && $this->getToString() != '') $recipients .= 'TO:'.$this->getToString().self::$lineEnding;
		if ($this->getCCString() != '') $recipients .= 'CC:'.$this->getCCString().self::$lineEnding;
		if ($this->getBCCString() != '') $recipients .= 'BCC:'.$this->getBCCString().self::$lineEnding;<commit_msg>Added workaround for mb_send_mail issue<commit_after><?php
namespace wcf\system\mail;
use wcf\data\language\Language;
use wcf\system\WCF;
use wcf\util\FileUtil;
use wcf\util\StringUtil;

/**
 * This class represents an e-mail.
 * 
 * @author	<NAME>
 * @copyright	2001-2013 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	data.mail
 * @category	Community Framework
 */
class Mail {
	/**
	 * line ending string
	 * @var string
	 */
	public static $lineEnding = "\n";
	
	/**
	 * mail header
	 * @var string
	 */
	protected $header = '';
	
	/**
	 * boundary for multipart/mixed mail
	 * @var string
	 */
	protected $boundary = '';
	
	/**
	 * mail content mime type
	 * @var string
	 */
	protected $contentType = "text/plain";
	
	/**
	 * mail recipients
	 * @var array<string>
	 */
	protected $to = array();
	
	/**
	 * mail subject
	 * @var string
	 */
	protected $subject = '';
	
	/**
	 * mail message
	 * @var string
	 */
	protected $message = '';
	
	/**
	 * mail sender
	 * @var array<string>
	 */
	protected $from = array();
	
	/**
	 * mail carbon copy
	 * @var array<string>
	 */
	protected $cc = array();
	
	/**
	 * mail blind carbon copy
	 * @var array<string>
	 */
	protected $bcc = array();
	
	/**
	 * mail attachments
	 * @var array
	 */
	protected $attachments = array();
	
	/**
	 * priority of the mail
	 * @var	integer
	 */
	protected $priority = 3;
	
	/**
	 * mail body
	 * @var	string
	 */
	protected $body = '';
	
	/**
	 * mail language
	 * @var wcf\data\language\Language
	 */
	protected $language = null;
	
	/**
	 * Creates a new Mail object.
	 * 
	 * @param	string		$to
	 * @param	string		$subject
	 * @param	string		$message
	 * @param	string		$from
	 * @param	string		$cc
	 * @param	string		$bcc
	 * @param	array		$attachments
	 * @param	integer		$priority
	 * @param	string		$header
	 */
	public function __construct($to = '', $subject = '', $message = '', $from = '', $cc = '', $bcc = '', $attachments = array(), $priority = '', $header = '') {
		$this->setBoundary();
		
		if (empty($from)) $from = array(MAIL_FROM_NAME => MAIL_FROM_ADDRESS);
		if (empty($priority)) $priority = 3;
		
		$this->setFrom($from);
		$this->setSubject($subject);
		$this->setMessage($message);
		$this->setPriority($priority);
		$this->setHeader($header);
		
		if (!empty($to)) $this->addTo($to);
		if (!empty($cc)) $this->addCC($cc);
		if (!empty($bcc)) $this->addBCC($bcc);
		
		if (!empty($attachments)) $this->setAttachments($attachments);
	}
	
	/**
	 * Creates and returns a basic header for the email.
	 * 
	 * @return	string		mail header
	 */
	public function getHeader() {
		if (!empty($this->header)) {
			$this->header = preg_replace('%(\r\n|\r|\n)%', self::$lineEnding, $this->header);
		}
		
		$this->header .=
			'X-Priority: 3'.self::$lineEnding
			.'X-Mailer: WoltLab Community Framework Mail Package'.self::$lineEnding									
			.'From: '.$this->getFrom().self::$lineEnding
			.($this->getCCString() != '' ? 'CC:'.$this->getCCString().self::$lineEnding : '')
			.($this->getBCCString() != '' ? 'BCC:'.$this->getBCCString().self::$lineEnding : '');
			
		if (count($this->getAttachments())) {
			$this->header .= 'Content-Transfer-Encoding: 8bit'.self::$lineEnding;
			$this->header .= 'Content-Type: multipart/mixed;'.self::$lineEnding;
			$this->header .= "\tboundary=".'"'.$this->getBoundary().'";'.self::$lineEnding;
		}
		else {
			$this->header .= 'Content-Transfer-Encoding: 8bit'.self::$lineEnding;
			$this->header .= 'Content-Type: '.$this->getContentType().'; charset=UTF-8'.self::$lineEnding;
		}
		
		// until PHP 5.3.4 mb_send_mail() appends an extra MIME-Version header
		// @see: https://bugs.php.net/bug.php?id=52681
		if (MAIL_SEND_METHOD != 'php' || version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION, '5.3.4', '>=')) {
			$this->header .= 'MIME-Version: 1.0'.self::$lineEnding;
		}
		
		return $this->header;
	}
	
	/**
	 * Creates and returned the recipients list (TO, CC, BCC).
	 * 
	 * @param	boolean		$withTo
	 * @return	string
	 */
	public function getRecipients($withTo = false) {
		$recipients = '';
		if ($withTo && $this->getToString() != '') $recipients .= 'TO:'.$this->getToString().self::$lineEnding;
		if ($this->getCCString() != '') $recipients .= 'CC:'.$this->getCCString().self::$lineEnding;
		if ($this->getBCCString() != '') $recipients .= 'BCC:'.$this->getBCCString().self::$lineEnding;
{'fraction_non_alphanumeric': 0.19979176307265156, 'fraction_numerical': 0.004974548819990745, 'mean_word_length': 3.311720698254364, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 87, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7387288', 'n_tokens_mistral': 3323, 'n_tokens_neox': 2938, 'n_words': 630}