Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require 'PHPMailer-master/src/Exception.php';
- require 'PHPMailer-master/src/PHPMailer.php';
- require 'PHPMailer-master/src/SMTP.php';
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPSecure = "tls";
- $mail->port = "587";
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;
- $mail->Username = "myaddress@gmail.com";
- $mail->Password = "mypassword";
- $mail->From = "myaddress@gmail.com";
- $mail->FromName = "Alex";
- $mail->AddAddress("myaddress@gmail.com", "Alex");
- $mail->AddReplyTo("myaddress@gmail.com", "Information");
- $mail->WordWrap = 50;
- $mail->IsHTML(true);
- $mail->Subject = "Here is the subject";
- $mail->Body = "This is the HTML message body in bold!";
- $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
- $mail->SMTPDebug = 2;
- if(!$mail->Send()){
- $er=$mail->ErrorInfo;
- $json = array("error" => "X", "errorMsg" => $er);
- }else{
- $json = array("error" => "X", "error" => "Message has been sent");
- }
- echo json_encode($json);
- return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement