Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require_once('../vendor/autoload.php');
- $mail = new PHPMailer(); // create a new object
- $mail->IsSMTP(); // enable SMTP
- $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
- $mail->SMTPAuth = true; // authentication enabled
- $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail
- $mail->Host = "smtp.gmail.com";
- $mail->Port = 587; // or 465 ssl
- $mail->IsHTML(true);
- $mail->Username = "username@gmail.com";
- $mail->Password = "password";
- $mail->SetFrom("example@gmail.com");
- $mail->Subject = "Test";
- $mail->Body = "hello";
- $mail->AddAddress("toAddress");
- //Added to example code to make it work from Azure
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- if(!$mail->Send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
- } else {
- echo "Message has been sent";
- }
- ?>
Add Comment
Please, Sign In to add comment