This script says my message was ucessfully sent. I don't recaive any emails. Please can someone help me.
<?php
//set variable error var
$er = 0;
//enter the website the contact form is on
$website = 'jonathan@jcomputingconsultants.co.uk';
//Set all POST variables
$email = $_POST['email'];
$name = $_POST['name'];
$hereaboutus = $_POST['hereaboutus'];
$nameto = "jonathan@jcomputingconsultants.co.uk";
//check email
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email)) {
$er = 1;
}
//check name
if(!ereg("^[A-Za-z'.-]", $name)) {
$er = 1;
}
//check hereaboutus
if(!ereg("^[a-zA-Z0-9-]", $hereaboutus)) {
$er = 1;
}
if ($er == 1) {
header("Location: contacterror.php");
}
if ($er == 0) {
// strip slashes if magic quotes on (default).
if (get_magic_quotes_gpc()) {
$message = stripslashes( $message );
}
//wordwrap
$message = wordwrap($message, 70);
// enter the mail address the form is sent to
$to = 'jonathan@jcomputingconsultants.co.uk';
//from
$from = $email;
// subject
$subject = "NEW! INFOMATION Pack Request From $website Online";
// message
$message = "
<html>
<head>
<title>INFOMATION Pack Request From NEW SITE $website Online</title>
</head>
<body>
<p><b>Message from:</b> $name</p>
<p><b>E-mail Address:</b> $email</p>
<p><b>They heard About Your Site In Or By:</b> $hereaboutus</p>
</body>
</html>
";
authSendEmail($email, $name, $to, $nameto, $subject, $message);
}
/* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */
//This will send an email using auth smtp and output a log array
//logArray - connection,
function authSendEmail($email, $name, $to, $nameto, $subject, $message)
{
//SMTP + SERVER DETAILS
/* * * * CONFIGURATION START * * * */
$smtpServer = "smtp.emailsrvr.com";
$port = "587";
$timeout = "30";
$username = "jonathan@jcomputingconsultants.co.uk";
$password = "***********";
$localhost = "localhost";
$newLine = "\r\n";
/* * * * CONFIGURATION END * * * * */
//Connect to the host on the specified port
$smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);
$smtpResponse = fgets($smtpConnect, 515);
if(empty($smtpConnect))
{
$output = "Failed to connect: $smtpResponse";
return $output;
}
else
{
$logArray['connection'] = "Connected: $smtpResponse";
}
//Request Auth Login
fputs($smtpConnect,"AUTH LOGIN" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authrequest'] = "$smtpResponse";
//Send username
fputs($smtpConnect, base64_encode($username) . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authusername'] = "$smtpResponse";
//Send password
fputs($smtpConnect, base64_encode($password) . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authpassword'] = "$smtpResponse";
//Say Hello to SMTP
fputs($smtpConnect, "HELO $localhost" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['heloresponse'] = "$smtpResponse";
//Email From
fputs($smtpConnect, "MAIL FROM: $email" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailfromresponse'] = "$smtpResponse";
//Email To
fputs($smtpConnect, "RCPT TO: [email]jonathan@jcomputingconsultants.co.uk[/email]" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailtoresponse'] = "$smtpResponse";
//The Email
fputs($smtpConnect, "DATA" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['data1response'] = "$smtpResponse";
//Construct Headers
$headers = "MIME-Version: 1.0" . $newLine;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
$headers .= "To: [email]jonathan@jcomputingconsultants.co.uk[/email] <Mick Clare>" . $newLine;
$headers .= "From: $name <$email>" . $newLine;
fputs($smtpConnect, "To: [email]jonathan@jcomputingconsultants.co.uk[/email]\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n");
$smtpResponse = fgets($smtpConnect, 515);
$logArray['data2response'] = "$smtpResponse";
// Say Bye to SMTP
fputs($smtpConnect,"QUIT" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['quitresponse'] = "$smtpResponse";
header ("Location: contactsuccess.php "); die();
}
?>