0

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();
}
?>

Edited by Dani: Formatting fixed

2
Contributors
7
Replies
9
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Last line always redirects to success.php. There is no error handling at all. Remove it and output the logarray instead.

0

Cheers Pritaeas, I now receive this error below:

array(10) { ["connection"]=> string(90) "Connected: 220-telford.theukhost.net ESMTP Exim 4.69 #1 Tue, 14 Feb 2012 16:56:03 +0000 " ["authrequest"]=> string(75) "220-We do not authorize the use of this system to transport unsolicited, " ["heloresponse"]=> string(25) "220 and/or bulk e-mail. " ["authusername"]=> string(43) "503 AUTH command used when not advertised " ["authpassword"]=> string(67) "250 telford.theukhost.net Hello localhost.localdomain [127.0.0.1] " ["mailfromresponse"]=> string(26) "500 unrecognized command " ["mailtoresponse"]=> string(26) "500 unrecognized command " ["data1response"]=> string(27) "550 Authentication failed " ["data2response"]=> string(0) "" ["quitresponse"]=> string(0) "" }

0
220-We do not authorize the use of this system to transport unsolicited
220 and/or bulk e-mail.

You're not allowed to use it.

0

Cheers do u have any ideas how a can setup a contact page using smtp validation any other way.

0

No. It's so frustrating this smtp authentication and most hosts are now doing the same thing. I know it's for security just frustating at times like this.

0

You could try PHPMailer for example, instead of writing your own protocol, but it may not work if relaying is not allowed on that mail server.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.