Having trouble with PHPMailer

后端 未结 7 1021
渐次进展
渐次进展 2020-11-28 09:24

I am trying to use PHPMailer to send a gmail email. I followed this post

In order to do this, I set up a function shown below:

function sendEmail($         


        
7条回答
  •  感动是毒
    2020-11-28 09:55

    I have send mail from xampp server from localhost

    This code is perfectly work for me

    1: down load phpmailer from https://github.com/PHPMailer/PHPMailer

    2: go to xampp and search php.ini

    3 In php.ini search

    ;extension=php_openssl.dll    
     remove(;)       
     extension=php_openssl.dll 
    

    then save and restart p.c. its work

    <%php 
    require_once("C:\\xampp\\phpMailer\\PHPMailer-master\\class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->SMTPAuth = true; // Enable SMTP authentication
    $mail->SMTPSecure = 'ssl' ;
    $mail->Host = "smtp.gmail.com" ;// SMTP server
    $mail->Port = 465; // or 587
    $mail->Username = 'senderemailid@gmail.com'; // SMTP username
    $mail->Password = 'senderpassword'; // SMTP password
    $mail -> IsHTML(true);
    $mail->From = 'senderemailid@gmail.com';
    $mail->FromName = 'sendername';
    $mail->addAddress('receiveremailid@domain.com','receivername');
    $mail->WordWrap = 50;
    $mail->Subject = "This mail send from PhP code xampp";
    $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
    if(!$mail->Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
    } else
    {
    echo 'Message has been sent.';
    }
    ?>

提交回复
热议问题