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($
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.';
}
?>