Results 1 to 3 of 3

Thread: PHP Mailto Script Help Plz!

  1. #1
    mattemme is offline x10Hosting Member
    Join Date
    Jun 2012
    Posts
    1

    PHP Mailto Script Help Plz!

    Hi Everyone!

    I'm new to this site and am using it to help promote my new photography hobby. I'm trying desperately to implement a simple mailto form so that people can contact me without revealing my own email address. I'm having problems getting it to work though. Can anyone suggest/provide a script to use (as I'm not smart enough in these things to write one myself)? Or is it possible that it's x10's hosting that isn't allowing it to go through? I would appreciate any help possible.

    Thanks so much

  2. #2
    gameaddict2085 is offline x10Hosting Member
    Join Date
    Jul 2011
    Posts
    82

    Re: PHP Mailto Script Help Plz!

    <?php
    // This function checks for email injection. Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
    function isInjected($str) {
    $injections = array('(\n+)',
    '(\r+)',
    '(\t+)',
    '(%0A+)',
    '(%0D+)',
    '(%08+)',
    '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if(preg_match($inject,$str)) {
    return true;
    }
    else {
    return false;
    }
    }

    // Load form field data into variables.
    $email_address = $_REQUEST['email_address'] ;
    $comments = $_REQUEST['comments'] ;

    // If the user tries to access this script directly, redirect them to feedback form,
    if(!isset($_REQUEST['email_address'])) {
    header( "Location: index.html" );
    }

    // If the form fields are empty, redirect to the error page.
    elseif (empty($email_address) || empty($comments)) {
    header( "Location: ErrorPage.html" );
    }

    // If email injection is detected, redirect to the error page.
    elseif ( isInjected($email_address) ) {
    header( "Location: ErrorPage.html" );
    }

    // If we passed all previous tests, send the email!
    else {

    date_default_timezone_set('America/Los_Angeles');
    //echo date('l jS \of F Y h:i:s A');
    //echo " ... testing the mail() function " ;

    $from = "youraccountname@yourdomain"; // MUST BE LEGIT ACCOUNT ON YOUR DOMAIN

    $to="[email protected]" ; // CURRENTLY, not blocked by hotmail!

    $mailbody= $email_address."
    ".$comments;
    $subject="Site Email" ;

    $headers = "Content-type: text/plain; charset=windows-1251 \r\n"; // MUST BE text/plain
    $headers .= "From: $from\r\n";
    $headers .= "Reply-To: $from\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "X-Mailer: PHP/" . phpversion();

    $resp = mail($to, $subject, $mailbody, $headers);

    if( $resp ){
    header( "Location: ErrorPage.html" );
    }else{
    header( "Location: ErrorPage.html" );
    }

    ?>
    Edit the above to match your details and save as Email.php
    Then add this form to your webpage:

    <form method='post' action='Email.php'>
    <input type='text' name='email_address' value='' />
    <input type='text' name='comments' value='' />
    </form>
    I adapted this from someone else's work but I can't remember where I got it so all credit goes to somebody else
    Last edited by gameaddict2085; 06-06-2012 at 05:52 PM.
    Check out Photon GameManager: http://photongamemanager.com/
    Check out our large database of free games: http://thefreegamesdb.com

  3. #3
    ellescuba27 is offline x10 Lieutenant
    Join Date
    Sep 2011
    Posts
    267

    Re: PHP Mailto Script Help Plz!

    Where's your submit button gameaddict2085?
    Also, wouldn't it be better to use an SMTP Mailer like PHPMailer so Qmail doesn't open?
    And yes, email can be sent through x10, but only with your cPanel email. You can't use x10 to connect to your personal mail.

Similar Threads

  1. [PHP] Script terminating in middle of script for no reason
    By jkmaster9918 in forum Scripts, 3rd Party Apps, and Programming
    Replies: 2
    Last Post: 04-09-2010, 05:08 PM
  2. Changing the default mailto address
    By benphoto in forum Scripts, 3rd Party Apps, and Programming
    Replies: 7
    Last Post: 10-18-2009, 08:16 PM
  3. 50 Credits for Bash Script/Php Script
    By javajenius in forum Classifieds
    Replies: 0
    Last Post: 04-21-2008, 10:40 PM
  4. Sending a form to an email without the mailto: statement
    By ilstu in forum Scripts, 3rd Party Apps, and Programming
    Replies: 2
    Last Post: 10-26-2007, 12:57 AM
  5. Anti Spam Mailto: links
    By Richard in forum Scripts, 3rd Party Apps, and Programming
    Replies: 6
    Last Post: 07-10-2005, 09:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
dedicated servers