@kaley
To test PHP mailer code in XAMPP, you can follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<?php use PHPMailerPHPMailerPHPMailer; use PHPMailerPHPMailerException; require 'vendor/autoload.php'; $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.example.com'; $mail->SMTPAuth = true; $mail->Username = 'your@example.com'; $mail->Password = 'yourpassword'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('from@example.com', 'Your Name'); $mail->addAddress('to@example.com'); $mail->isHTML(true); $mail->Subject = 'Test Email'; $mail->Body = 'This is a test email.'; $mail->send(); echo 'Email sent successfully'; } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo; } ?> |
By following these steps, you can easily test your PHP mailer code using XAMPP on your local machine.