<?php
	if(file_exists("system.mail/PHPMailerAutoload.php"))
		require_once("system.mail/PHPMailerAutoload.php");
	else
		require_once("../system.mail/PHPMailerAutoload.php");
	
	class systemMAIL {
		public function submitRegistrationMail($mReceiverMail, $mReceiverName) {
			global $systemHandler;
			$l = $systemHandler->loadHandler("LANG");
			$mCollection = $l->mLangCollection["mail"];
			
			$systemConfig = $systemHandler->loadHandler("CONFIG");
			$mMailer = new PHPMailer;
			$mMailer->isSMTP();
			$mMailer->Host = $systemConfig->mMail["SMTP_HOST"];
			$mMailer->SMTPAuth = true;
			$mMailer->Username = $systemConfig->mMail["OWN_EMAIL"];
			$mMailer->Password = $systemConfig->mMail["OWN_EMAIL_PASS"];
			$mMailer->Port = $systemConfig->mMail["SMTP_PORT"];
			$mMailer->SMTPSecure = 'tls';
			
			$mMailer->From = $systemConfig->mMail["OWN_EMAIL"];
			$mMailer->FromName = $systemConfig->mMail["EMAIL_SENDER_NAME"];
			$mMailer->addAddress($mReceiverMail, $mReceiverName);
			$mMailer->isHTML(true);
			$mMailer->Subject = $systemConfig->mSocialName." - ".$mCollection["welcome"]." ".$mReceiverName.'!';
			$mMailer->Body = "<strong>Hey ".$mReceiverName."!</strong><br /><br />".$mCollection["yourregistrationat"]." ".$systemConfig->mSocialName." ".$mCollection["wassuccessful"]."!";
			$mMailer->AltBody = "Hey ".$mReceiverName."! ".$mCollection["yourregistrationat"]." ".$systemConfig->mSocialName." ".$mCollection["wassuccessful"]."!";
			$mMailer->send();
		}
		
		public function submitLostPassMail($mUserId) {
			global $systemHandler;
			$l = $systemHandler->loadHandler("LANG");
			$mCollection = $l->mLangCollection["mail"];
			
			$systemConfig = $systemHandler->loadHandler("CONFIG");
			$systemUser = new systemUSER($mUserId);
		
			$mMailer = new PHPMailer;
			$mMailer->isSMTP();
			$mMailer->Host = $systemConfig->mMail["SMTP_HOST"];
			$mMailer->SMTPAuth = true;
			$mMailer->Username = $systemConfig->mMail["OWN_EMAIL"];
			$mMailer->Password = $systemConfig->mMail["OWN_EMAIL_PASS"];
			$mMailer->Port = $systemConfig->mMail["SMTP_PORT"];
			$mMailer->SMTPSecure = 'tls';
			
			$mMailer->From = $systemConfig->mMail["OWN_EMAIL"];
			$mMailer->FromName = $systemConfig->mMail["EMAIL_SENDER_NAME"];
			$mMailer->addAddress($systemUser->mMail, $systemUser->mFullname);
			$mMailer->isHTML(true);
			$mMailer->Subject = $systemConfig->mSocialName." - ".$mCollection["pwresetfor"]." ".$systemUser->mFullname.'!';
			$mMailer->Body = "<strong>Hey ".$systemUser->mFirstname."!</strong><br /><br />".$mCollection["requestedpwreset"]."<br/ ><br />".$mCollection["toreset"].": ".$systemConfig->mCompletePath."/index.php?reset=".$systemUser->mLostHash;
			$mMailer->AltBody = "Hey ".$systemUser->mFirstname."! ".$mCollection["requestedpwreset"]." ".$mCollection["toreset"].": ".$systemConfig->mCompletePath."/index.php?reset=".$systemUser->mLostHash;
			$mMailer->send();
		}
		
		public function submitPasswordMail($mUserId, $mNewPass) {
			global $systemHandler;
			$l = $systemHandler->loadHandler("LANG");
			$mCollection = $l->mLangCollection["mail"];
			
			$systemConfig = $systemHandler->loadHandler("CONFIG");
			$systemUser = new systemUSER($mUserId);
		
			$mMailer = new PHPMailer;
			$mMailer->isSMTP();
			$mMailer->Host = $systemConfig->mMail["SMTP_HOST"];
			$mMailer->SMTPAuth = true;
			$mMailer->Username = $systemConfig->mMail["OWN_EMAIL"];
			$mMailer->Password = $systemConfig->mMail["OWN_EMAIL_PASS"];
			$mMailer->Port = $systemConfig->mMail["SMTP_PORT"];
			$mMailer->SMTPSecure = 'tls';
			
			$mMailer->From = $systemConfig->mMail["OWN_EMAIL"];
			$mMailer->FromName = $systemConfig->mMail["EMAIL_SENDER_NAME"];
			$mMailer->addAddress($systemUser->mMail, $systemUser->mFullname);
			$mMailer->isHTML(true);
			$mMailer->Subject = $systemConfig->mSocialName." - ".$mCollection["newpasswordfor"]." ".$systemUser->mFullname.'!';
			$mMailer->Body = "<strong>Hey ".$systemUser->mFirstname."!</strong><br /><br />".$mCollection["resetpw"].".<br/ ><br />".$mCollection["newpsis"].": <strong>".$mNewPass."</strong>";
			$mMailer->AltBody = "Hey ".$systemUser->mFirstname."! ".$mCollection["resetpw"].". ".$mCollection["newpwis"].": ".$mNewPass;
			$mMailer->send();
		}
	}
?>