I've recently moved hosts and now with the contact form I have to use SMTP. I have been able with some help get something to work but am unable to retrieve the information I need from the form. The information I am trying to pull is name email phone and message. This is what I have been using
<?php
require "email.php";
$mail = new EMail;
$mail->Username = 'username.co.uk';
$mail->Password = 'mypassword';
$mail->SetFrom("no-reply@mywebsite.co.uk","no-reply@mywebsite.co.uk"); // Name is optional
$mail->AddTo("no-reply@mywebsite.co.uk","no-reply@mywebsite.co.uk"); // Name is optional
$mail->Subject = "Hello World Again!";
$mail->Message = "Hello World!";
//Optional
$mail->ContentType = "text/html"; // Defaults to "text/plain; charset=iso-8859-1"
$mail->Headers['X-SomeHeader'] = 'abcde'; // Set some extra headers if required
$mail->ConnectTimeout = 30; // Socket connect timeout (sec)
$mail->ResponseTimeout = 8; // CMD response timeout (sec)
$success = $mail->Send();
?>
When I test this an email gets sent but of course only the "Hello World" text gets sent as I'm unsure where to put the necessary code to pull the info I need.
Prior to moving hosts and not needing SMTP I was using this script
<?php
//-----------------------------------------------------
//-----------------------------------------------------
$address= "myemail.co.uk";
//-----------------------------------------------------
//-----------------------------------------------------
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$message_content = $_REQUEST["message"];
$mime_boundary = md5(time());
$headers = "From: $name <$email>
";
$headers .= "Reply-To: $subject <$email>
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"
";
$message = "-- $mime_boundary
";
$message .= "New email from the Commons website:
";
$message .= "Name: $name
";
$message .= "Email: $email
";
$message .= "Phone: $phone
";
$message .= "Message: $message_content
";
$message .= "--$mime_boundary--
";
$mail_sent = mail($address, $subject, $message, $headers);
echo $mail_sent ? "Success, mail sent!" : "Mail failed";
?>
Thanks in advance
Kind Regards
Tim