>

Thursday, November 10, 2016

smtp.php

<?php
include("../../../conn.php");
$con=new connection();
$r=$con->display_smtp_configuration();

while($row=mysql_fetch_array($r)){

$id=$row[0];

$row[0];
$row[1];
$adminemail = $row[1];
$row[2];
$smtpemail = $row[2];
$Host = $row[3];
$row[4];
$port = $row[4];
$row[5];
$smtppass = $row[5];

}


$login_user=$_GET['login_user'];
//session_start();
/**
 * This example shows making an SMTP connection with authentication.
 */

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');

require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
// $mail->Host = "ssl://Linuxindia2.securehostdns.com";
$mail->Host = $Host;
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = $port;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
$mail->CharSet = "UTF-8";
//Username to use for SMTP authentication
$mail->Username = $smtpemail;
//Password to use for SMTP authentication
$mail->Password = $smtppass;
//Set who the message is to be sent from
$mail->setFrom($smtpemail, 'English-sikho.com Report');
//Set an alternative reply-to address
$mail->addReplyTo($smtpemail, 'English-sikho.com Report');
//Set who the message is to be sent to
$mail->addAddress($login_user, "$login_user");
$mail->addAddress($adminemail, "$login_user");//send to admin...
//Set the subject line
$mail->Subject = 'English-sikho Report';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body

//$mail->msgHTML(file_get_contents('mail_page.php'), dirname(__FILE__));

$File="mail_page.php";

//$output = shell_exec("php -n -s $File");
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
function get_data($url){
$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$data=curl_exec($ch);
curl_close($ch);
return $data;
}

$examids=$_GET['examids'];
$language=$_GET['language'];


if($_SESSION[language] == "Gujrati")
{
$returned=get_data("http://englishsikho.nhnfoods.com/mail/2/examples/mail_pageguj.php?examids=$examids&login_user=$login_user");

$mail->msgHTML($returned);$mail->AltBody = 'This is a plain-text message body';

if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    header("location:http://englishsikho.nhnfoods.com/Thankyouguj.php");
}
}
else
{
$returned=get_data("http://englishsikho.nhnfoods.com/mail/2/examples/mail_pageeng.php?examids=$examids&login_user=$login_user");

$mail->msgHTML($returned);$mail->AltBody = 'This is a plain-text message body';

if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    header("location:http://englishsikho.nhnfoods.com/Thankyoueng.php");
}

}

?>