AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 3.16.130.96


Current Path : /var/www/lhjmq-records.qc.ca/public_html/xsl/records/booknew/php_mailer/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/xsl/records/booknew/php_mailer/sendmail.class.php

<?php

define('DEBUG', false);

class SendMail {
	var $email_name;
	var $email_from;
	var $email_to;
	var $email_subject;
	var $email_body;
	var $email_alt_body;
	var $attachments;
	
	function send_email($debug = false) {
		include_once('phpmailer.class.php');
		
		$oMail = new PHPMailer();
		$oMail->FromName = $this->email_name;
		$oMail->FromEmail = $this->email_from;
		$oMail->Subject = $this->email_subject;
		$oMail->AddAddress($this->email_to);
		$oMail->IsHTML(true);
		
		if (count($this->attachments) > 0) {
			foreach ($this->attachments as $i => $attachment) {
				$oMail->AddAttachment($attachment['attachment_physical_file'], $attachment['attachment_file_name'], 'base64', $attachment['attachment_file_type']);
			}
		}
		
		$oMail->Body = '';
		$oMail->Body .= '<html>'."\n";
		$oMail->Body .= '<head>'."\n";
		$oMail->Body .= '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n";
		$oMail->Body .= '<meta http-equiv="content-language" content="en-us">'."\n";
		$oMail->Body .= '</head>'."\n";
		$oMail->Body .= '<body style="font-family: arial; color: #000000;">'."\n";
		$oMail->Body .= '<table cellpadding="5" cellspacing="0" border="0">'."\n";
		
		if (DEBUG == true || $debug == true) {
			$oMail->Body .= '<tr><td height="10" colspan="3">'."\n";
			$oMail->Body .= '<span style="font-family: arial; color: #000000; font-size: 12px;">';
			$oMail->Body .= '<b>Email from name:</b> '.$this->email_name.'<br /><br />';
			$oMail->Body .= '<b>Email from:</b> '.$this->email_from.'<br /><br />';
			$oMail->Body .= '<b>Email to:</b> '.$this->email_to.'<br /><br />';
			$oMail->Body .= '<b>Email subject:</b> '.$this->email_subject.'<br /><br />';
			$oMail->Body .= '</span><hr /><br />';
			$oMail->Body .= '</td></tr>'."\n";
		}
		
		foreach ($this->email_body as $email_line) {
			$tmp = explode('|', $email_line);
			
			if (count($tmp) == 1 && strlen($tmp[0]) == 0) {
				$oMail->Body .= '<tr><td height="10" colspan="3">&nbsp;</td></tr>'."\n";
			}
			else if (count($tmp) == 1 && strlen($tmp[0]) > 1) {
				$oMail->Body .= '<tr><td colspan="3" style="font-size: 12px;">'.trim($email_line).'</td></tr>'."\n";
			} 
			else {
				if (trim($tmp[1]) != '') {
					$oMail->Body .= '
						<tr>
							<td style="font-size: 12px;" valign="top" nowrap>'.trim($tmp[0]).'</td>
							<td width="10"></td>
							<td style="font-size: 12px;">'.trim($tmp[1]).'</td>
						</tr>
					'."\n";
				}
			}
		}
		
		$oMail->Body .= '</table>'."\n";
		$oMail->Body .= '</body>'."\n";
		$oMail->Body .= '</html>';
		$oMail->AltBody = $this->email_alt_body;
		
		if (DEBUG == true || $debug == true) {
			echo $oMail->Body.'<br /><br /><br /><br />';
			echo $oMail->AltBody.'<br /><br /><br /><br />';
			
			return true;
		}
		else {
			if ($oMail->Send()) {
				$oMail->ClearAllRecipients();
				$oMail->ClearAttachments();
				
				return true;
			}
		}
		
		return false;
	}
}

?>