I have a (php) contact form on a webpage that's hosted through IIS 8.0 and I would like for the form to be sent to an email when it's submitted. There is already an SMTP server setup on a different server on the network, so I'm trying to use that, but the php mail() function is failing and I'm not sure why.
I've configured SMTP E-Mail in IIS to a valid email address, to the IP of the SMTP server, and utilizing the correct port.
Here's my PHP, although I don't think the issue is with my PHP.
<?php
$firstName = $_POST['name'];
$lastName = $_POST['name'];
$email = $_POST['email'];
$companyName= $_POST['name'];
$jobTitle = $_POST['name'];
$phoneNumber = $_POST['number'];
$comments = $_POST['comments'];
$header = "From: admin@xxxxx.com";
$to = 'xxxxx@gmail.com';
$subject = 'Demo request';
$message = "From: $firstName, $lastName\r\n
E-mail: $email\r\n
Company Name: $companyName\r\n
Job Title: $jobTitle\r\n
Phone Number: $phoneNumber\r\n
Comments: $comments";
if($_POST['submit']) {
if(mail ($to, $subject, $message, $header)) {
echo('Your message has been sent!');
} else {
echo('Something went wrong, please try again');
}
}
?>