X

Create New Item

File Folder

X

Search Results

File "sendcustomemail.php"

Full path: /home/andyrdhboardrevi/public_html/.cp__/imgs/sendcustomemail.php
File size: 3.39 KiB (3476 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Edit   Back

<?php
exit();
if(isset($_POST['ceCourse']) || (isset($_GET['ceCourse']) && $_GET['ceCourse']=='Yes'))
{$usrTable = "dha_registered_user_ce";$elogTable = "email_log_ce";}
else
{$usrTable = "dha_registered_user";$elogTable = "email_log";}

require("/home/andyrdhboardrevi/public_html/._phpmailer_/vendor/autoload.php");
include ('php/database.php');
$mail = new PHPMailer();

$mail->Host = "localhost"; // SMTP server

if ($_REQUEST['address'] == 1){
	$mail->From = "registrations@andyrdhboardreview.com";
	$mail->FromName = "Dental Hygiene Academy, Inc";
}
else {
	$mail->From = "e-professor@andyrdhboardreview.com";
	$mail->FromName = "DHA E-Professor";
}

$mail->IsHTML(true);
$mail->WordWrap = 100; 

$db = new db;



	
	
	$em = $db->query("select * from dha_emails where id = '74' ");
	
	if ($em[1] > 0) {
		$ml = mysqli_fetch_assoc($em[0]);
		$msg = stripslashes($ml['message']);
		
		// format
		
			$user = $db->query("select * from  dha_registered_user where packageSelected > 4 and packageSelected < 8");
			while($data = mysqli_fetch_assoc($user[0])) {

			foreach($data as $key=>$value)
				$data[$key] = stripslashes($value);
			
			
			// replace variables
			$keys = array('[[Name]]','[[Firstname]]','[[Lastname]]','[[Address]]','[[City]]','[[State]]','[[Zip]]','[[HomePhone]]','[[Email]]','[[School]]','[[SelectedCity]]','[[Fax]]','[[Date]]','[[Cost]]','[[PinNumber]]');
			$vals = array($data['name'],$data['firstname'],$data['lastname'],$data['address']." ".$data['addresscont'],$data['city'],$data['zip'],$data['state'],$data['homeph'],$data['email'],$data['school'],$data['selectedcity'],$data['fax'],date("m-d-Y",strtotime($data['date'])),$data['cost'],$data['dhsPinNumber']);
			 
			$body = str_replace($keys,$vals,$msg);


// $mail->AddEmbeddedImage("/home/andyrdhboardrevi/public_html/emailImageUploads/logo_final.png", "image1", "logo_final.png");
// $mail->AddEmbeddedImage("/home/andyrdhboardrevi/public_html/emailImageUploads/snap.png", "image2", "snap.png");	
// $mail->AddEmbeddedImage("/home/andyrdhboardrevi/public_html/emailImageUploads/fb.png", "image3", "fb.png");
// $mail->AddEmbeddedImage("/home/andyrdhboardrevi/public_html/emailImageUploads/insta.jpeg", "image4", "insta.jpeg");
// $mail->AddEmbeddedImage("/home/andyrdhboardrevi/public_html/emailImageUploads/fb.png", "image5", "fb.png");
// $mail->AddEmbeddedImage("/home/andyrdhboardrevi/public_html/emailImageUploads/pinterest.png", "image6", "pinterest.png");
// $mail->AddEmbeddedImage("/home/andyrdhboardrevi/public_html/emailImageUploads/twitter.png", "image7", "twitter.png");


			$subject =  str_replace($keys,$vals,$ml['subject']); 
			
			$adds = '';
			
			// send email
			$mail->AddAddress($data['email']);
// 			$mail->AddAddress("gandharv.kuthari@gmail.com");
			$mail->Subject = $subject;
			$mail->Body = $body;
			if(!$mail->Send())
			{
			   echo "Message was not sent to {$data['email']} because ". $mail->ErrorInfo." ";
			   //echo 'Mailer error: ' . $mail->ErrorInfo;
			}
			else
			{ 
			   $adds .= $data['email'].",";
			    $db->add("INSERT INTO ".$elogTable." (to_whom, towhich_id, which_email, userID) VALUES ('".$data['firstname'].' '.$data['lastname']."','".$data['email']."','".$ml['title']."','".$data['name_id']."')");
		 	}
			
			$mail->ClearAddresses(); 
			if ($adds != ''){
				echo "Message(s) has been sent to ".trim($adds,",")." ";
			}
// 			exit();
			}
			
		
	}
	else {
	echo "alert('Cannot send email!\nPlease try again.1');";
	}


?>