42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
|
// Include PHPMailer library files
|
|
require 'src/Exception.php';
|
|
require 'src/PHPMailer.php';
|
|
require 'src/SMTP.php';
|
|
|
|
$mail = new PHPMailer;
|
|
|
|
// SMTP configuration
|
|
$mail->isSMTP();
|
|
$mail->Host = $_POST['server']; // Client's mail server
|
|
$mail->SMTPAuth = true;
|
|
$mail->Username = $_POST['username']; // Client's email username
|
|
$mail->Password = $_POST['password']; // Client's password
|
|
if ($_POST['encryption'] != "none") {
|
|
$mail->SMTPSecure = $_POST['encryption'];
|
|
}
|
|
$mail->Port = $_POST['port']; // SMTP Port
|
|
|
|
// Mail configuration
|
|
$mail->setFrom($_POST['from-email'], 'Tester'); // Email From field
|
|
|
|
// Recipient info
|
|
$mail->addAddress($_POST['recipient-email']); // Email To field
|
|
$mail->Subject = 'PHPMailer over SMTP Test'; // Email Subject field
|
|
$mail->Body = 'This email has been sent using PHPMailer (over SMTP) for test purposes.'; // Email Body field
|
|
|
|
// Send email report
|
|
if(!$mail->send()) {
|
|
echo '<span style="color: red;">Message could not be sent.</span><br>';
|
|
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
|
} else {
|
|
echo '<span style="color: green;">Message has been sent.</span><br>';
|
|
echo 'Server: ' . $_POST['server'] . '<br>';
|
|
echo 'Port: ' . $_POST['port'] . '<br>';
|
|
echo 'Encryption: ' . $_POST['encryption'] . '<br>';
|
|
echo 'Username: ' . $_POST['username'];
|
|
}
|