I am sending mail through ajax call using php mailer.
Ajax Call:
$(document).on("click","#EmailMe",function(){
$datatable = $("#DivProductContainer").html();
$.ajax({
url: "pages/mail.php",
type: 'POST',
data: {Args: $datatable}
}).done(function(data){
if(data){
alert("success");
}else{
alert("Not success");
}
});
});
PHP File:
<?php
require '../class.phpmailer.php';
require '../class.smtp.php';
require '../class.pop3.php';
$html = $_POST["Args"];
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "My Gmail ID"; // GMAIL username
$mail->Password = "My Gmail Password"; // GMAIL password
$mail->From = '[email protected]';
$mail->FromName = 'John';
$mail->AddAddress('[email protected]', 'Tester'); // Add a recipient
$mail->AddAddress('[email protected]'); // Name is optional
$mail->AddReplyTo('[email protected]', 'Contact person');
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Testing Mail';
$mail->Body = 'testing goes here <b>HTML</b> $html';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
?>
Output: Content in Body of mail:
testing goes here HTML $html
I receive DataString from ajaxcall is(that is assign in $html):
I want to render this html in-stand of $html in Mail.
Please help me to get out of here..I am trying it last two days and i test many more option but i did not get proper solution. Thanks in Advance.