<?php
require_once 'autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
$host = "smtp.websitelive.net";
$port = 587;
$username = "you@your-email-here.com";
$password = "YourPasswordHere";
$from = "you@your-email-here.com";
$to = "to@to-email-here.com";
$replyto = "reply-to@your-email-here.com";
$subject = "Hi!";
$body = "Hi,\n\n Test from my website";
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = $host;
$mail->Port = $port;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAuth = true;
$mail->Username = $username;
$mail->Password = $password;
$mail->setFrom($from);
$mail->addAddress($to);
$mail->addReplyTo($replyto);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->isHTML(false); // set to true if sending HTML email
$mail->send();
echo "<p>Message successfully sent!</p>";
} catch (Exception $e) {
echo "<p>There was an error!</p>";
echo "<p>" . $mail->ErrorInfo . "</p>";
}
?> |