This is my HTML form, which is inside a little box on my site.
<form name="contactform" action="contact/form-mailer.php" method="post">
<p>*Name: <input name="Name" id="Name" size="25"></p>
<p>*Pickup from: <input name="pfrom" id="pform" size="25"></p>
<p>*Destination: <input name="destin" id="destin" size="25"></p>
<p>*E-mail: <input name="Email" id="Email" size="25"></p>
<p>*Phone: <input name="Phone" id="Phone" size="25"></p>
<p><input type="submit" value="Submit" name="submitform"><input type="reset" value="Reset" name="reset"></p>
</form>
And this is my current PHP for sending the mail using PEAR. I haven't added all of the variables into the $body yet, as I've just been trying to get it to actually work.
<?php
// Include the Mail package
//require "Mail.php";
include 'Mail.php';
// Identify the sender, recipient, mail subject, and body
$sender = "XXXXXX";
$recipient = "XXXXXX";
$subject = "FORM";
$body = $name; // Even when seting $name in the PHP file it still doesn't show!
// Identify the mail server, username, password, and port
$server = "ssl://smtp.gmail.com";
$username = "XXXXXXXX";
$password = "XXXXXXXX";
$port = "465";
// Get form var's
$name = "Test"; // I set $name to "Test" in the PHP and still the variable does not appear in the email.
$destin = $_POST['destin'];
$email = $_POST['Email'];
$pfrom = $_POST['pfrom'];
// Set up the mail headers
$headers = array(
"From" => $sender,
"To" => $recipient,
"Subject" => $subject
);
// Configure the mailer mechanism
$smtp = Mail::factory("smtp",
array(
"host" => $server,
"username" => $username,
"password" => $password,
"auth" => true,
"port" => 465
)
);
// Send the message
$mail = $smtp->send($recipient, $headers, $body);
if (PEAR::isError($mail)) {
echo ($mail->getMessage());
}
?>
So I have no idea why this isn't working. I need body to be like this
$body = $name . " wants to go to " . $destin . " from " . $pfrom;
But it just doesn't pickup any variables, regardless of whether I am trying to get them from the HTML form or set them in the PHP file itself. I was expecting this to be really easy, but this has stumped me for over a day now. Very frustrating. I can find no example anywhere that shows you how to do it, and only a handful have asked this exact question and received no definitive answer.