Following is my code and I am using google apps for business. I have replaced my password with * in the following code. I am using apache2.
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Port = 465; // SMTP Port
$mail->Username = "adminbot@mycompany.com"; // SMTP account username
$mail->Password = "*********"; // SMTP account password
$mail->SetFrom('adminbot@mycompany.com', 'John Doe'); // FROM
$mail->AddReplyTo('adminbot@mycompany.com', 'John Doe'); // Reply TO
$mail->AddAddress('ZTruse1955@mycompany.com', 'Jane Doe'); // recipient email
$mail->Subject = "First SMTP Message"; // email subject
$mail->Body = "Hi! \n\n This is my first e-mail sent through Google SMTP using PHPMailer.";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
When I open the page I get blank with no mail received upon opening the page. Do I need to install any php libraries for this to work apart from default lap installation?
I have shared two different mail methods for your requirement..
First case;
Second case; (http://ctrlq.org/code/19589-send-mail-php)
Try it and hope it will solve your issues !