| Current Path : /var/www/html/mmishra/iws8/html/indem/ |
| Current File : /var/www/html/mmishra/iws8/html/indem/deomail.php |
<h2>Personal Group Mailing </h2>
<?php
include "functions.inc";
$toAddress = $_POST["toAddress"];
$greet = $_POST["greet"];
$subject = $_POST["subject"];
$mailbody = $_POST["mailbody"];
if ($_FILES["filename"]["name"]) $attachement = $_FILES["filename"]["name"];
?>
Please select recepient group, greeting format and type in subject and mailbody for group mailing.
<form action="deomail.php" method="post">
<center>
<table border="1" width="70%" style="border-collapse: collapse">
<tr>
<td width="25%">Receipent:</td>
<td>
<input type="radio" name="toAddress" value="faculty"
<?php
if ($toAddress == "faculty") echo " checked";
?>
> Faculty
<input type="radio" name="toAddress" value="officer"
<?php
if ($toAddress == "officer") echo " checked";
?>
> Officer
<input type="radio" name="toAddress" value="staff"
<?php
if ($toAddress == "staff") echo " checked";
?>
> Staff
</td>
</tr><tr>
<td>Greeting:</td>
<td>
<input type="radio" name="greet" value="1"
<?php
if ($greet == "1") echo " checked";
?>
> by Surname (e.g. Dear Prof. Rao)
<input type="radio" name="greet" value="2"
<?php
if ($greet == "2") echo " checked";
?>
> by Fisrtname (e.g. Dear Dr. Mohit)
</td>
</tr><tr>
<td>Subject:</td><td><input type="text" name="subject" size="50" value='<?php echo $subject; ?>'></td>
</tr><tr>
<td>Mailbody:</td><td><textarea name="mailbody" rows="6" cols="40"><?php echo $mailbody; ?></textarea></td>
</tr><tr>
<td>Attachment:</td><td><input type="file" name="filename" size="50" value=''></td>
</tr><tr>
<td></td><td><input type="submit" name="submit" value="SUBMIT"> <input type="reset" name="reset" value="RESET"></td>
</tr>
</table>
</center>
</form>
<?php
if ($_POST["submit"] == 'SUBMIT') {
require("classes/class.phpmailer.php");
$ds = ldap_connect("ldap.iiita.ac.in");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$rs = ldap_search($ds, "ou=employee,dc=iiita,dc=ac,dc=in", "(&(employeetype=*$toAddress)(objectclass=posixAccount))");
$info = ldap_get_entries($ds, $rs);
for ($i = 0; $i < $info["count"]; $i++) {
$no++;
$dn = $info[$i]["dn"];
$uid = $info[$i]["uid"][0];
$ttl = $info[$i]["initials"][0];
$fn = $info[$i]["givenname"][0];
$sn = $info[$i]["sn"][0];
$email = $info[$i]["mail"][0];
if ($greet == "1") $greeting = 'Dear '.$ttl.' '.$sn;
else $greeting = 'Dear '.$ttl.' '.$fn;
echo "<center><table width='70%' border='1'><tr><td>
<div align='right'>Ref.No. IIIT/$no/".date("Y")."</div>
<center><b><u>Sub: $subject</u></b></center>
<div>$greeting<br><br><dir>$mailbody</dir></div>
</td></tr></table></center><br>";
/*
//if (checkEmail($email)) {
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.iiita.ac.in"; // SMTP server
$mail->FromName = "Nationa Seminar on Solar Energy Empowering Rural India";
$mail->From = "seminarict@iiita.ac.in";
//$mail->AddAddress("seminarict@iiita.ac.in","Coordinator");
$mail->AddAddress($email,$email);
$mail->AddCC("mmishra@iiita.ac.in","mmishra");
$mail->Username = "indem";
$mail->Password = "mac2011";
$mail->Subject = $subject;
$mail->WordWrap = 80;
if ($_FILES["filename"]["name"]) $mail->AddAttachment($_FILES["filename"]["tmp_name"],$_FILES["filename"]["name"]);
$mail->Body = "
Dear $greeting
$mailbody
";
//if ($mail->Send()) {
// echo "An email acknowledgement will be sent by the Seminar Coordinator.\n";
//} else {
// echo "An email acknowledgement will be sent by the Seminar Coordinator.\n";
//}
echo $mail->Body."\n";
//} else
// exit('Invalid email address');
*/ }
ldap_close($ds);
}
?>