Skip to content

Instantly share code, notes, and snippets.

@asraraljuhani
Last active June 14, 2021 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asraraljuhani/92c728432547b6a31f2494730de253bc to your computer and use it in GitHub Desktop.
Save asraraljuhani/92c728432547b6a31f2494730de253bc to your computer and use it in GitHub Desktop.
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "ALMousallauqu@gmail.com";
$mail->Password = "";
$mail->SetFrom("ALMousallauqu@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("asrar@gmail.com");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
@asraraljuhani
Copy link
Author

Download PHPMailer.php and SMTP.php files from here
https://github.com/PHPMailer/PHPMailer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment