Created
March 17, 2018 16:39
-
-
Save thedineshj/b4e468a55b9f04c17d19198635578435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
require 'PHPMailer-6.0.3/src/Exception.php'; | |
require 'PHPMailer-6.0.3/src/PHPMailer.php'; | |
require 'PHPMailer-6.0.3/src/SMTP.php'; | |
$toAddress = "xxxxxxxxxxxx@yyyy.com"; //To whom you are sending the mail. | |
$message = <<<EOT | |
<html> | |
<body> | |
<h>PHPMailer basic usage</h> | |
<p>It is working</p> | |
</body> | |
</html> | |
EOT; | |
$mail = new PHPMailer(); | |
$mail->IsSMTP(); | |
$mail->SMTPAuth = true; | |
$mail->Host = "smtp.gmail.com"; | |
$mail->Port = 587; | |
$mail->SMTPOptions = array( | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false, | |
'allow_self_signed' => true | |
) | |
); | |
$mail->IsHTML(true); | |
$mail->Username = "xxxxxxxxxxxxx@gmail.com"; // your gmail address | |
$mail->Password = "xxxxxxxxxxx"; // password | |
$mail->SetFrom("***************@gmail.com"); | |
$mail->Subject = "Using PHPMailer without composer"; // Mail subject | |
$mail->Body = $message; | |
$mail->AddAddress($toAddress); | |
if (!$mail->Send()) { | |
echo "Failed to send mail"; | |
} else { | |
echo "Mail sent succesfully"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment