quick contact


$subject = “efa rock”;
//
// The following line sets the email address to use as the envelope
// sender. If the server fails to deliver the message, this is where
// the failure notice will go (obviously, if this is the same as
// deliveryEmail above, then it’s not going to help).
$envelopeFrom = “marketing@grishart.com”;

// If useSMTP is set to TRUE, PEAR SMTP auth functionality will be used
// If FALSE, then PHP mail() command and local sendmail will be used
$useSMTP = FALSE;

// If useSMTP is set to TRUE, then if the message fails, in addition to
// saying failed, the program can show the server response as well.
$showSMTPerrors = FALSE;

// If $useSMTP = “yes” then you must set these properly otherwise they
// are not required:
$smtphost = “smtp.mydomain.co.uk”; // SMTP server
$smtpuser = “mailboxname@mydomain.co.uk”; // SMTP username
$smtppass = “mailbox_password”; // SMTP password
/* End user defined variables */

if (isset ($_POST[‘iteration’])) { $iteration = $_POST[‘iteration’]; } else { $iteration = “”; }

/* ========================================================================= */
/* First iteration – show form */
/* ========================================================================= */
if (!$iteration) {
?>


\n”;
$errors = FALSE;

if (!$name) {
$errors = TRUE;
$errmsg .= “

  • You must enter a contact name.\n”;
    } else {
    if (!eregi (‘^[[:alnum:]\.\,\’\(\) \-]{4,}$’, stripslashes(trim($name)))) {
    $errors = TRUE;
    $errmsg .= “

  • Name must contain only letters, numbers and basic punctuation and be at least four characters long.\n”;
    }
    }

    if ($telephone) {
    if (!eregi (‘^[[:digit:]\.\+\(\) \-]{6,}$’, stripslashes(trim($telephone)))) {
    $errors = TRUE;
    $errmsg .= “

  • The telephone number should contain only numbers, period, plus sign, brackets, spaces and hyphen and be at least 6 digits long.\n”;
    }
    }

    if ($email) {
    if (!isEmail($email)) {
    $errors = TRUE;
    $errmsg .= “

  • Invalid email address. This field may optionally be left blank if a telephone number is provided.\n”;
    }
    }

    if (!$email && !$telephone) {
    $errors = TRUE;
    $errmsg .= “

  • No telephone number or email address. Please enter at least one.\n”;
    }

    if ($subject) {
    if (!eregi (‘^[[:alnum:]\.\,\’\(\) \-]{4,}$’, stripslashes(trim($subject)))) {
    $errors = TRUE;
    $errmsg .= “

  • If one is entered, the message subject must contain only letters, numbers and basic punctuation and be at least four characters long.\n”;
    }
    }

    if ($errors) { // failed validation
    $errmsg .= “

    \n”;
    ?>

    Sorry, but the following errors occurred whilst validating your message:


    Please use your browsers back button to return to the form and try again.

    “, $fmtmsg);
    $emailmsg = “Name………… {$name}\n”;
    $emailmsg .= “Telephone……. {$telephone}\n”;
    $emailmsg .= “Email Address… {$email}\n”;

    $emailmsg .= “\n{$fmtmsg}”;
    $to = “\”$deliverTo\”<$deliveryEmail>“;
    if ($email != “”) {
    $headers = “From: \”{$name}\”<{$email}>\n”;
    $from = “{$name} <{$email}>“;
    } else {
    $headers = “From: \”{$name} (NO EMAIL)\”<$deliveryEmail>\n”;
    $from = “{$name} (NO EMAIL) <$deliveryEmail>“;
    }
    $headers .= “X-Mailer: $xMailer [mail()]”;

    if ($useSMTP) {
    require_once “Mail.php”;

    $headers = array (‘Return-Path’ => $envelopeFrom,
    ‘From’ => $from,
    ‘To’ => $to,
    ‘Subject’ => $subject,
    ‘X-Mailer’ => “{$xMailer} [PEAR SMTP]”);

    $smtp = Mail::factory(‘smtp’,
    array (‘host’ => $smtphost,
    ‘auth’ => true,
    ‘username’ => $smtpuser,
    ‘password’ => $smtppass));

    $mail = $smtp->send($to, $headers, $emailmsg);

    // error checking sample code to show if send was successful
    if (PEAR::isError($mail)) {
    // Message sending failed
    $sendOK = FALSE;
    } else {
    // Message successfully sent
    $sendOK = TRUE;
    }
    } else {
    if (mail ($to, $subject, $emailmsg, $headers, ‘-f ‘.$envelopeFrom)) {
    $sendOK = TRUE;
    } else {
    $sendOK = FALSE;
    }
    }

    if (!$telephone) $telephone = ” “;
    if (!$subject) $subject = ” “;
    if (!$email) $email = ” “;

    /* Out put message to web browser */
    if ($sendOK) {
    ?>

    Thank you for contacting Dancewise Studios, we will respond to your enquiry shortly.

    \n”);
    }
    } // end of if sendOK statement

    } // end of validation if statement
    }
    ?>

  • Comments are closed.