Well I got this to work.
First this is modifying a procedural PHP script that I found some time ago with a OPPs PHP tutorial that I saw maby a week ago and stuffing the procedural script into the OOP version.
I tested in my developing environment and I can send emails from my home machine and then the emails are redirected back to my mail box. I don?t see why it won?t work on my site but I will put it up there tomorrow and check.
The routine required me to create an account that I left in place so that it reads better where the username email and passwords go.
There are two files. The style sheet is not enclosed in this email but if you ignore the HTML you should be able to follow the flow of the contact form that collects the information is sent to a second file that checks some parameters and concatenates others and sends the file. It?s not a big deal if you know PHP, but I don?t.
One more thing I just realized that I did not mention the second file needs presentation, I did not put that in yet.
contactform.php
content="software engineer, web development, graphics, website design, PHP, MySQL, Java, JavaScript, HTML, CSS," />
content="The Home page of William Bradley Rouse. Includes software and work description." />
content="Copyright ? 2008 William Bradley Rouse. All Rights Reserved." />
W. Bradley Rouse - About Me
<?php include("include/branding.inc"); ?>
<?php include("include/leftContent.inc"); ?>
Contact Form
All Fields required
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
OOP Contact Form
Name:
Email Address:
Phone:
Attention:
Web Developoment
Web Related Assistance
Java Assistance
Technical Support
Employment
Photography
Hobbies
Time of day to call back:
Morning
After Noon
Evening
Questions/Comments:
sendEmail02.php
<?php
// This won't except comments with http in it?
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$name = trim ($_POST['name']);
$email = trim($_POST['email']);
$phone = trim($_POST['phone']);
$attn = trim($_POST['attn']);
$con_time = trim($_POST['con_time']);
$comments = trim($_POST['comments']);
$site_owners_email = 'mailer@rouse.ws'; // Replace this with your own email address
$site_owners_name = 'William Rouse'; // replace with your name
// Cheap check for a vaild name
if (strlen($name) < 2) {
$error['name'] = 'Please enter your name';
}
// check for a valid email address [have no idea how this works
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address";
}
// check for a valid comment
if (strlen($comments) < 3) {
$error['comments'] = 'Please leave a comment.';
}
if (!$error) {
require_once ('phpMailer/class.phpmailer.php'); // bring in the include file
$todayis = date("l, F j, Y, g:i a") ; //get todays date
$myMail = new PHPMailer();
$myMail->From = $email;
$myMmail->FromName = $name;
$myMail->Subject = 'Website Contact Form';
$myMail->AddAddress($site_owners_email, $site_owners_name);
$myMail->AddAddress('mailer@rouse.ws');
$myMail->Body = "$todayis [CST] \n
Attention: $attn \n
Contact Time: $con_time \n
Message: $comments \n
From: $name \n
Phone: $phone \n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
From the Rouse web site.\n
";
$myMail->Mailer = 'smtp';
$myMail->Host = 'mail.rouse.ws';
$myMail->Port = 2525; //Site Ground email suggest this //587; //465 Original author suggested last 2
$myMail->SMTPSecure = 'tls';
$myMail->SMTPAuth = true; // turn on SMTP authentication
$myMail->Username = 'mailer+rouse.ws'; // SMTP username
$myMail->Password = 'pr0gramm3r'; // SMTP password -- Don't know
$myMail->Send();
echo " Congratulations, '.$name.'. We've received your email. We'll be in touch as soon as we possibly can! ";
} # end if no error
else {
$response = ( isset ($error['name']))?''.$error['name'].' \n':null;
$response .= ( isset ($error['email']))?''.$error['email'].' \n':null;
$response .= ( isset ($error['comments']))?''.$error['comments'].'':null;
echo $response;
} # end if there was an error sending
?>
WBR