244 lines
4.7 KiB
PHP
244 lines
4.7 KiB
PHP
<?php header('Content-type: application/json');
|
|
|
|
$em="";
|
|
|
|
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/mailservices/includes/');
|
|
|
|
include(PATHTOINCLUDES."base.php");
|
|
|
|
require_once(PATHTOINCLUDES."/PHPMailer_5.2.1/class.phpmailer.php");
|
|
|
|
$dbcon=dbconnect2();
|
|
|
|
$sql="SELECT
|
|
|
|
`mail_accounts`.`username`,
|
|
|
|
`mail_accounts`.`password`,
|
|
|
|
`mail_accounts`.`host`,
|
|
|
|
`mail_accounts`.`port`
|
|
|
|
FROM
|
|
|
|
`mail_accounts`
|
|
|
|
WHERE `mail_accounts`.`maid`=".$_SESSION["inbox_maid"];
|
|
|
|
$result=mysql_query($sql) or $em=$em.mysql_error();
|
|
|
|
$m=mysql_fetch_assoc($result);
|
|
|
|
|
|
|
|
$thetemplate=file_get_contents ("http://bateworld.com/mailservices/email/forward_email_inbox.html");
|
|
|
|
$timestamp=date("m-d-Y H:i");
|
|
|
|
$sys_ea = str_replace('@b8world.com','',$m["username"]);
|
|
|
|
$imapuid=$_POST["muid"];
|
|
|
|
$recipient=$_POST["recipient"];
|
|
|
|
$subject=$_POST["subject"];
|
|
|
|
$memo=$_POST["memo"];
|
|
|
|
$receive_date=$_POST["receive_date"];
|
|
|
|
|
|
|
|
$thebody = $_POST["thebody"];
|
|
|
|
//tidy_clean_repair($thebody);
|
|
|
|
|
|
|
|
$orig_subj=$_POST["osubject"];
|
|
|
|
$orig_subj=str_replace('Subject:', '', $orig_subj);
|
|
|
|
$orig_subj=str_replace('Subject', '', $orig_subj);
|
|
|
|
$mem_email=$_POST["mem_email"];
|
|
|
|
$mem_nic=$_POST["mem_nick"];
|
|
|
|
$mem_mailstatus=$_POST["mem_mailstatus"];
|
|
|
|
//params="subject" + subject + "&recipient=" + recipient + "&memo=" + optmsg + "
|
|
|
|
//&osubject=" + orig_subject + "&thebody=" + thebody + "&mem_email=" + mem_email +
|
|
|
|
//"&mem_nic=" + mem_nic + "&mem_mailstatus=" + mem_mail_status + "receive_date=" + orig_rdate;
|
|
|
|
$footer="System Mail v1.0";
|
|
|
|
$nav="From: ".$sys_ea." ".$timestamp;
|
|
|
|
$thetemplate=str_replace('[nav]', $nav, $thetemplate);
|
|
|
|
$thetemplate=str_replace('[footer]', $footer, $thetemplate);
|
|
|
|
//echo $message;
|
|
|
|
$sql2="SELECT `users`.`firstname`,
|
|
|
|
`users`.`mi`,
|
|
|
|
AES_DECRYPT(`users`.`lastname`,'".$wordgames."') AS lname,
|
|
|
|
AES_DECRYPT(`users`.`email`,'".$wordgames."') AS emailaddress
|
|
|
|
FROM `users`
|
|
|
|
WHERE `users`.`uid` IN(".$recipient.")";
|
|
|
|
$result2=mysql_query($sql2) or $em=$em.mysql_error();
|
|
|
|
while ($row = mysql_fetch_assoc($result2)) {
|
|
|
|
$salutation="<p>Hi " .$row["firstname"].",</p>";
|
|
|
|
if($memo !=""){$memo="<p>".$memo."</p>";}
|
|
|
|
$mailinfo="<div style=\"padding-top:20px;\">";
|
|
|
|
$mailinfo .="<div>Message Recieved: ".$receive_date."</div>";
|
|
|
|
$mailinfo .="<div>Subject: ".$orig_subj."</div>";
|
|
|
|
$mailinfo .="<div>Member's Email: ".$mem_email."</div>";
|
|
|
|
$mailinfo .="<div>Member's Display Name: ".$mem_nic."</div>";
|
|
|
|
$mailinfo .="<div>Member's Mail Status: ".$mem_mailstatus."</div>";
|
|
|
|
$mailinfo .="</div>";
|
|
$fmsg="";
|
|
|
|
$fmsg .="<div style=\"padding-top:20px;\">";
|
|
|
|
$fmsg .="<div>Fowarded Message _ _ _ _ _ _</div>";
|
|
|
|
$fmsg .="<p>".$thebody."</p>";
|
|
|
|
$fmsg .="</div>";
|
|
|
|
$message=$salutation.$memo.$mailinfo.$fmsg;
|
|
|
|
//$message = tidy_parse_string($message);
|
|
|
|
//tidy_clean_repair($message);
|
|
|
|
$thetemplate=str_replace('[content]',$message,$thetemplate);
|
|
|
|
$message=$thetemplate;
|
|
|
|
$recipient=$row["emailaddress"];
|
|
|
|
$subject=$subject;
|
|
|
|
$charset="UTF-8";
|
|
|
|
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
|
|
|
|
$mail->IsSMTP(); // telling the class to use SMTP
|
|
|
|
try {
|
|
|
|
$mail = new PHPMailer();
|
|
|
|
$mail->IsSMTP(); // telling the class to use SMTP
|
|
|
|
$mail->Host = "b8world.com"; // SMTP server
|
|
|
|
$mail->SMTPAuth = true; // authentication enabled
|
|
|
|
$mail->Port = 587;
|
|
|
|
// $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
|
|
|
|
$mail->CharSet = $charset;
|
|
|
|
$mail->Username = $m["username"]; // SMTP account username
|
|
|
|
$mail->Password = $m["password"]; // SMTP account password
|
|
|
|
//$mail->From = "mailservices@b8world.com";
|
|
|
|
$mail->SetFrom($m["username"], 'Bateworld');
|
|
|
|
$mail->AddReplyTo($m["username"], 'Bateworld');
|
|
|
|
$mail->AddAddress($recipient);
|
|
|
|
|
|
|
|
$mail->Subject = $subject;
|
|
|
|
//$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
|
|
|
|
$mail->MsgHTML($message);
|
|
|
|
//$mail->AddAttachment('mailer/images/phpmailer.gif'); // attachment
|
|
|
|
//$mail->AddAttachment('mailer/images/phpmailer_mini.gif'); // attachment
|
|
|
|
|
|
|
|
$mail->Send();
|
|
|
|
//echo "Message Sent OK<p></p>\n";
|
|
|
|
} catch (phpmailerException $e) {mail("phil@b8world.com", "MAIL ERROR", $e->errorMessage());
|
|
|
|
//echo $e->errorMessage(); //Pretty error messages from PHPMailer
|
|
|
|
} catch (Exception $e) {
|
|
|
|
//echo $e->getMessage(); //Boring error messages from anything else!
|
|
|
|
mail("phil@b8world.com", "MAIL ERROR", $e->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}//end while
|
|
|
|
|
|
|
|
if (($mbox = imap_open("{b8world.com:143/novalidate-cert}INBOX", $m["username"], $m["password"])) !=false)
|
|
|
|
{
|
|
|
|
$move="INBOX.Forwarded";
|
|
|
|
if(imap_mail_move ( $mbox , $imapuid , $move, CP_UID))
|
|
|
|
{
|
|
|
|
imap_expunge($mbox);
|
|
|
|
imap_close($mbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$em=$em."Failed To Move";
|
|
|
|
}
|
|
|
|
|
|
|
|
$arr = array ('result'=>$em);
|
|
|
|
echo json_encode($arr);
|
|
|
|
?>
|