<?php include '../../login/dbc.php'; session_start(); require 'PHPMailer-master/PHPMailerAutoload.php'; function checkEmail($str) { return preg_match("/^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,4})\$/", $str); } switch ($_GET['action']) { case 'sendInvite': sendInvite(); break; case 'sendConfirmation': send_confirmation(); break; } function sendInvite() { function get_include_contents($filename, $variablesToMakeLocal) { extract($variablesToMakeLocal); if (is_file($filename)) { ob_start(); include $filename; return ob_get_clean(); } return false; } $emailData = $_POST['emailData']; foreach ($emailData as $key) {
// If $email is not set, $message is empty so as $youremail, then show the form if (!isset($email)) { echo $inviteForm; } elseif (empty($youremail)) { die("Your unique identifier is missing"); } elseif (empty($email)) { echo $inviteForm; echo "<font color='red' size=5>Please enter the Recipient's Email </font>"; } elseif (empty($subject)) { echo $inviteForm; echo "<font color='red' size=5>Please enter the subject! </font>"; } elseif (empty($message)) { echo $inviteForm; echo "<font color='red' size=5>Please enter the message! </font>"; } else { $send = sendInvite($email, $subject, $message); // If we can not send this email let's show the error if (!$send) { echo "Can not send your invitation!"; } else { echo "<font color='blue' size=6>Invitation has been sent to " . $email . ". Now you can close this window</font>"; } } ?> <?php function sendInvite($to, $subject, $message) { $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: CALTTubes@insead.edu' . "\r\n" . 'Reply-To: CALTTubes@insead.edu' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$row = mysql_fetch_array($result); $name = $row['name']; $subject = "[" . $full_tubename . "]" . " Invitation for watching the video : " . $name; $query = "SELECT name FROM peoplenodes where id ='{$youremail}'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $personname = $row['name']; $pr = "This invitation to you comes from " . $personname . " (" . $youremail . ")"; $vURL = $full_tubeurl . "?actionName=playvideoByPassLogin&userName=anonymous@gmail.com&key=lab1&videoid=" . $vid; $message2 = "You have been invited to watch the video called <b>" . $name . "</b> in " . $full_tubename . ".<br><br>"; $message2 = $message2 . "Please click below to access the video. <br> "; $message2 = $message2 . $vURL; $message2 = $message2 . "<br><br>" . $pr; $message = $message2; /* error_log("To List " . $toList); error_log("subject " . $subject); error_log("message " . $message); */ $send = sendInvite($toList, $subject, $message); $send = true; // If we can not send this email let's show the error if (!$send) { $rspMessage = "Can not send your invitation!"; } else { $rspMessage = "Success"; } $retstring = $retstring . "<message>" . $rspMessage . "</message></rsp>"; echo $retstring; ?>