Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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):

enter image description here

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.

share|improve this question
    
So is the email sending? How are you getting this output? –  Conner Douglass Jun 19 '13 at 18:07
    
Conner Douglass@ Yes It all about email sending... –  Rickyrock Jun 20 '13 at 4:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.