Email & Database submission

Discussion in 'PHP' started by dannbkk, Jun 10, 2007.

  1. #1
    Once this form is submitted the info goes to database, but for some reason its im not getting a copy to my email which i should be, im not understanding why? what code will i need to add or modify to get a copy to my email account...

    <?php
    require_once('db.inc.php');
    if (isset($_POST['sell_submit'])) {
    if ($_POST['biz_type'] == 'Business Type' || $_POST['email'] == 'Email Address') {
    echo 'Please hit the back button and fill up the 2 fields.';
    exit();
    } elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
    echo 'Email not valid.';
    exit();
    } else {
    $to = 'info@email.com';
    $eol = "\r\n";
    $subject = 'WEBSITE (Sell Business)';
    $headers .= 'From: Website Business<info@email.com>'.$eol;
    $headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
    $headers .= 'MIME-Version: 1.0 '.$eol;
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
    $headers .= "X-Mailer: PHP v".phpversion().$eol;
    $body = 'Someone had submitted the form at sell-submit.php and here\'s the informations,<br>';
    $body .= 'Email: '.$_POST['email'].'<br>';
    $body .= 'Business Type: '.$_POST['biz_type'].'<br>';
    $body .= 'Warm Regards,<br><br>';
    $body .= 'WEBSITE<br>';
    $body .= 'www.website.com<br>';
    $body .= 'www.website.com';
    mail($to, $subject, $body, $headers);
    }
    ?>
    PHP:

     
    dannbkk, Jun 10, 2007 IP
  2. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #2
    try using the following code:

    $ok = @mail($to, $subject, $body, $headers);
    if(! $ok) {
    die("Sorry but the email could not be sent. Please go back and try again!");
    }
     
    NoamBarz, Jun 10, 2007 IP
  3. dannbkk

    dannbkk Well-Known Member

    Messages:
    1,403
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    120
    #3
    nope still didnt get a copy to my email?
     
    dannbkk, Jun 11, 2007 IP
  4. tswebdesign

    tswebdesign Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've tried times to get the mail() function to work consistently. It is not going to happen. You should utilize PEAR Mail Package. If you are using a shared hosting plan, you may find that the mail() function is disabled to prevent spamming.
     
    tswebdesign, Jun 11, 2007 IP