-2

I've got a simple contact form:

<form method="post" name="submitted.php" action="submitted.php" autocomplete="off"> <br>
<input type="name" id="forename" name="forename" placeholder="Forename" required> <br>
<input type="name" id="surname" name="surname" placeholder="Surname" required> <br>
<input type="email" id="email" name="email" placeholder="Email" required> <br>
<input type="message" id="message" name="message" placeholder="Message" required> <br>
<br>
<input type="submit" name="submit" id="submit" value="Contact Me" required="">

That is supposed to email the form responses to the email address associated with the domain via phpmailer. The code was working and has all of a sudden just stopped.

submitted.php contains this code:

<?php

    use PHPMailer\PHPMailer\PHPMailer;

    if(isset($_POST['submit'])) 
    {
        // Values

        $forename = $_POST['forename'];
        $surname = $_POST['surname'];
        $email = $_POST['email'];
        $message = $_POST['message'];
  
        $timestamp =date('l jS \of F Y h:i:s A');

        require './vendor/autoload.php';

        $mail = new PHPMailer;
        $mail->isSMTP();
        $mail->SMTPDebug = 0;
        $mail->Host = 'smtp.hostinger.co.uk';
        $mail->Port = 587;
        $mail->SMTPAuth = true;
        $mail->Username = '[email@example.com';
        $mail->Password = '[PASSWORD]';
        $mail->SMTPSecure = 'tls';

        $mail->setFrom('noreply@example.com','Domain Noreply'); // Emails sent via Domain's Noreply

        $mail->addAddress('enquiries@example.com','Enquiries'); // Email form responses sent to enquiries@example.com

        $mail->addReplyTo($email,$forename.' '.$surname); // Reply to the user who submitted the form.

        $mail->addBCC('outbox@example.com',''); // Store record of all emails sent via the system in outbox@example.com

        $mail->Subject = 'Contact form response from '.$forename.' '.$surname.' '; // Subject of the email sent to enquiries that the form responses will be contained within.

        $mail->isHTML(TRUE);
        $mail->Body = <<<EOD
        
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html>
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <title>Contact Form Submission</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
            <style>
             /* Email Template */ 
            .mail-body {
                padding-top: 15px;
                padding-left: 15px:
            }

            .email-logo {
                padding-bottom: 10px;
            }

            a:link {
                text-decoration: none;
            }

            a:visited {
                text-decoration: none; 
            }

            hr {
                height: 5px;
                width: 100%;
                background-color: #000000;
                border: none;
            }
            </style>
            </head>
            <body>
            <div class="mail-body">
            <a href="https://example.com"><img class="email-logo" src="https://example.com/logo.png" width="200px"></a>
            <br>
            <p>Hey Enquiries,</p>
            <p>You have received a new form response from {$forename}.</p>
            <p>Please see below for their contact information and message they submitted.</p>
            <p>You can click their email address or reply below to start an email thread.</p>
            <br />
            <p><b>Contact Details:</b></p>
            <p>Name: {$forename} {$surname}</p>
            <p>Email: <a href="mailto:{$email}"> {$email}</a></p>
            <p><b>Request Details</b></p>
            <p>Message: {$message}</p>
            <br />
            <hr>
            <p>Please do not reply to this email</p>     
            </div>
            </body>
            </html>
          
EOD;
        if(!$mail->send()) { // Send the email.
          echo '';
          echo 'Mailer error: ' . $mail->ErrorInfo;
        } else {
          echo '';
        }
    }
?>

This code was working, and the emails did send successfully. I've been lost with this for about a month at this point so any help would be greatly appreciated.

1 Answers1

-1

try modifying the button that triggers the form

<input type="submit" value="Contact Me" required="">

for

<input name="submit" type="submit" value="Contact Me" required="">