🐘
send.php
Back
📝 Php ⚡ Executable Ctrl+S: Save • Ctrl+R: Run • Ctrl+F: Find
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require '/var/www/html/phpSource/phpMailer/Exception.php'; require '/var/www/html/phpSource/phpMailer/PHPMailer.php'; require '/var/www/html/phpSource/phpMailer/SMTP.php'; if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = htmlspecialchars($_POST['name']); $email = htmlspecialchars($_POST['email']); $message = htmlspecialchars($_POST['message']); $mail = new PHPMailer(true); try { // SMTP Settings $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'olinhll@gmail.com'; $mail->Password = 'iltfvboaunzggllx'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; // Sender / Recipient $mail->setFrom($email, $name); $mail->addAddress('olinhll@gmail.com'); // Email Content $mail->isHTML(false); $mail->Subject = 'New Contact Form Message'; $mail->Body = "Name: $name\nEmail: $email\n\nMessage:\n$message"; $mail->send(); echo "Message sent successfully!"; } catch (Exception $e) { echo "Message could not be sent. Error: {$mail->ErrorInfo}"; } } ?>