开发者

Ajax Jquery in PHPMailer SMTP

开发者 https://www.devze.com 2023-03-06 09:14 出处:网络
I have a problem in using phpmailer using ajax jquery. It will not send email to my recipient please help me here are the codes:

I have a problem in using phpmailer using ajax jquery. It will not send email to my recipient please help me here are the codes:

For my popupjob.php where it will process my ajax: $(document).ready(function(){ $('.submit').click(function(){

        for (var a=0; a < document.checkform.jobclient.length; a++)
            {
                if (document.checkform.jobclient[a].checked)开发者_运维问答{
                    var agentId = document.checkform.jobclient[a].value;
                    var dataString = 'action=sendMail&companyId=<?=$_SESSION['ses_companyid']?>&agentId=' + agentId; 
                    $.ajax({
                    cache: 'false',
                    type: "POST",  
                    url: "ajaxfunction.php",  
                    data: dataString,
                    success: function(msg){

                        }
                    }); 
                }
            }
});

});

My problem really is in my ajax.php. It will not send my email to the email address I inputted.

function func12(){

include('adodb/adodb.inc.php'); 
include "include/manager_shared.php";

?>
<html>
    <head>
    <title>PHPMailer - SMTP basic test with authentication</title>
    </head>
    <body>

    <?php

    //error_reporting(E_ALL);
    error_reporting(E_STRICT);

    date_default_timezone_set('America/Toronto');

    require_once('include/class.phpmailer.php');
    //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

    $mail             = new PHPMailer();

    $body             = file_get_contents('include/contents.html');
    $body             = eregi_replace("[\]",'',$body);

    $mail->IsSMTP(); // telling the class to use SMTP
     // SMTP server
    $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                               // 1 = errors and messages
                                               // 2 = messages only
    $mail->SMTPSecure= "ssl";
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->Host       = "smtp.mail.yahoo.com"; // sets the SMTP server
    $mail->Port       = 465;                    // set the SMTP port for the GMAIL server
    $mail->Username   = "username@domain"; // SMTP account username
    $mail->Password   = "mypassword";        // SMTP account password

    $mail->SetFrom('username@domain', 'First Last');

    $mail->AddReplyTo("username@domain","First Last");

    $mail->Subject    = "PHPMailer Test Subject via smtp, basic with authentication";

    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

    $mail->MsgHTML($body);

    $address = "johnDoe@gmail.com";
    $mail->AddAddress($address, "John Doe");
    if(!$mail->Send()) {
      echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "Message sent!";
    } 
    ?>

    </body>
    </html>

switch($_POST['action']){
    case 'sendMail':
        $output = func12();
        break;
    default:
        $output = '';
} 

echo $output; 

}

?>

Please help me. Replies are much appreciated........By the way I am using facebox in pop-upping my form. Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消