I've developed a website for a client (that will be hosted on their private server) that includes an enrollment form. Users input their first name, last name, email, phone number, and zip code. They also use a radio button to select if they've used the product before, and can check a box to receive news about the product.
That info is supposed to be sent using SMTP to an email address they handle. They then process the registry internally. So all it needs to do is collect the information and send it in an email. For the SMTP configuration the client has provided me with an IP address, a Port number, and they have stated that there is no Username or Password and no Encryption.
I have tried to follow many different tutorials online but I am new to PHP and have not been able to make it work.
Here is the html for the form:
<form id="enrollmentForm" name="email-form-3" action="" method="post" class="eForm">
<label for="nombre" class="labels">FIRST NAME</label>
<input type="text" class="w-input" maxlength="256" name="fName" id="fName" required="">
<label for="apellido" class="labels">LAST NAME</label>
<input type="text" class="text-field w-input" maxlength="256" name="lName" id="lName" required="">
<label for="email" class="labels">EMAIL</label>
<input type="text" class="w-input" maxlength="256" name="email" id="email" required="">
<label for="phone" class="labels">PHONE</label>
<input type="text" class="text-field-2 w-input" maxlength="256" name="phone" id="phone" required="">
<label for="zip" class="labels">ZIP CODE</label>
<input type="text" class="w-input" maxlength="256" name="zip" id="zip" required="">
<label class="labels check">HAVE YOU USED OUR PRODUCT BEFORE?</label>
<label id="usedBeforeYes" class="w-radio">
<input type="radio" name="usedBefore" id="si" value="si" data-name="usedBefore?" required="" class="w-form-formradioinput w-radio-input"><span class="labels w-form-label" for="si">YES</span></label>
<label id="usedBeforeNo" class="w-radio">
<input type="radio" name="usedBefore" id="no" value="no" data-name="usedBefore?" required="" class="w-form-formradioinput w-radio-input"><span class="labels w-form-label" for="no">NO</span></label>
<label class="w-checkbox">
<input type="checkbox" id="checkBox" name="checkBox" class="w-checkbox-input">
<span class="checkbox-label-2 w-form-label" for="checkbox-6">Would you like to receive more information about our product?</span>
</label>
<input type="submit" name="submit" value="SUBMIT" data-wait="One moment..." class="button w-button">
</form>
This is the PHP I have been trying to use:
<?php
if (isset($_POST["submit"]))
{
$message = "Info:" . "\n\n\n"
. "First Name: " . $_POST["fName"] . "\n"
. "Last Name: " . $_POST["lName"] . "]n"
. "Email: " . $_POST["email"] . "\n"
. "Phone Number: " . $_POST["phone"] . "\n"
. "Zip Code: " . $_POST["zip"] . "\n"
. "Repeat Customer?: " . $_POST["usedBefore"] . "\n"
. "Send news?: " . $_POST["checkBox"];
$mailTo = "internalEmail@client.com";
$subject = "Customer Registry";
require 'class\PHPMailer.php';
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->setFrom($mailTo, 'Registry');
$mail->Username = '';
$mail->Password = '';
$mail->Host = 'ip address provided';
$mail->Port = 'port provided';
$mail->SMTPSecure = 'tls';
$mail->From = $mailTo;
$mail->AddAddress($mailTo, 'Registry');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->Send();
if ($mail->Send())
{
echo('Message sent successfully');
}
else
{
echo('Error while sending message');
}
}
?>
Many thanks in advance!