Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/php/
Upload File :
Current File : /var/www/cesa.co.za/php/sendeventreg2.php

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/includes/load_phpmailer.php';

use PHPMailer\PHPMailer\PHPMailer;

require("inc_db.php");

function GenPassword()
{
	// Password generation 
	$length = 8; // Must be a multiple of 2
	$conso = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "x", "y", "z");
	$vocal = array("a", "e", "i", "o", "u");
	$password = "";
	srand((float)microtime() * 1000000);
	$max = $length / 2;
	for ($i = 1; $i <= $max; $i++) {
		$password .= $conso[rand(0, 19)];
		$password .= $vocal[rand(0, 4)];
	}

	return $password;
}

function CaseCorrect($str)
{
	$newstr = ucwords(strtolower($str));
	return $newstr;
}
function XMail($to, $subject, $msg, $from, $CC, $type)
{

	$mail = new PHPMailer;
	$mail->Mailer   = "mail";
	/*	
	$mail->Mailer="smtp";
	$mail->Host="relay.aitonline.co.za";
	$mail->Port=587;
	$mail->Username="mail@cesa.co.za";
	$mail->Password="c3SAmail!@!";
	$mail->SMTPDebug=false;
	$mail->SMTPAuth=true;
	*/
	if ($type == "html") $mail->IsHTML(true);

	$mail->From     = $from;
	$mail->FromName     = $from;
	$arrto = explode(",", $to);
	for ($i = 0; $i < count($arrto); $i++) {
		$mail->AddAddress($arrto[$i]);
	}
	$mail->Subject = $subject;
	$mail->Body = $msg;

	if (!$mail->Send()) echo $mail->ErrorInfo;
}

$sendfrom = "bonolo@cesa.co.za";
$sEmailFooter = "<p><b>Consulting Engineers South Africa</b><br>Tel: 011 463 2022<br>Website: www.cesa.co.za</p><p><img src='https://www.cesa.co.za/images/emailfooter.jpg'></p>";

$sql = "SELECT * FROM MarketingAttendees WHERE AttendeeID IN (3,4,5,8)";
$rec = mysql_query($sql);
while ($row = mysql_fetch_assoc($rec)) {
	$FirstName = $row["ContactFirstName"];
	$Surname = $row["ContactLastName"];
	$Email = $row["EmailAddress"];
	$sPassword = GenPassword();
	$sql = "UPDATE MarketingAttendees SET Password='" . $sPassword . "' WHERE AttendeeID=" . $row["AttendeeID"];
	echo $sql;
	mysql_query($sql);

	$msg = "<p>Dear " . $FirstName . " " . $Surname . ",</p>
<p>We are delighted to have received your online delegate registration for CESA Aon Awards Gala Dinner to be held from 18h00 to 23h00 on Wed 12 August 2015 at Vodaworld Midrand. Please direct any questions to marketing@cesa.co.za.</p><p>To reserve your table, please login at: <a href='https://www.cesa.co.za/eventtables'>https://www.cesa.co.za/eventtables</a> using your email address and the password: <b>" . $sPassword . "</b>. Please save this email for future reference.</p>
				<p>With kind regards,</p>
CESA Marketing</p>" . $sEmailFooter;

	XMail($Email, "Confirmation of CESA Event Registration", "<html>
				<head>
				<style>
				body, td { 
					font-family: Arial, Verdana, sans-serif;
					font-size: 11pt;
				}
				</style>
				</head>
				<body>" . $msg . "</body></html>", $sendfrom, "", "html");
}