#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    205
    Rep Power
    35

    Problem With Sending Mail


    I'm trying to have a form on my website where people can fill it out to request a quote. It will enter the quote request into a database and then send me an email with the details.

    My code below enters all the information into the database fine. However, the emails are not looking too good.

    Here is an example of what an email looks like when the visitor uses line breaks and ' in the fields:

    This is just a simple test. Nothing but a test.\r\n\r\nYep, this is just a test.\r\nAin\'t that cool?

    PHP Code:
    $name="$_POST[name]";
    $email="$_POST[email]";
    $phone="$_POST[phone]";
    $message="$_POST[service]";
    $ip=$_SERVER['REMOTE_ADDR'];

    $name stripslashes($name);
    $email stripslashes($email);
    $phone stripslashes($phone);
    $message stripslashes($message);

    $name mysql_real_escape_string($name);
    $email mysql_real_escape_string($email);
    $phone mysql_real_escape_string($phone);
    $message mysql_real_escape_string($message);

    // Make sure all required fields are used
    if(!$name){ die("Please go back and tell us your name"); }
    if(!
    $email){ die("Please go back and tell us your email address"); }
    if(!
    $message){ die("Please go back and tell us what type of service you are looking for"); }

    // Now send the email here
    $message wordwrap($message90);

    $to 'Name <email@email.com>';
    $subject 'Subject Here';
    $message2 "$name\n$email\n$phone\n\n$message\n\n======================================\nThis quote request was sent from:\n$_SERVER[HTTP_REFERER]";
        
    'Reply-To: $email' "\r\n" .
        
    'X-Mailer: PHP/' phpversion();
    $headers .= 'Content-type: text/html' "\r\n";

    mail"$to""$subject"$message2"From: $name <$email>"$headers ); 
    Thank You,

    Chet
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,337
    Rep Power
    594
    What happens when you use the 'wrap="hard"' attribute in your textarea tag?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    205
    Rep Power
    35
    Originally Posted by gw1500se
    What happens when you use the 'wrap="hard"' attribute in your textarea tag?
    nothing
    Thank You,

    Chet
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,337
    Rep Power
    594
    Looking at your code I don't see how it can even run.
    PHP Code:
    'Reply-To: $email' "\r\n" .
        
    'X-Mailer: PHP/' phpversion(); 
    These lines seem to constitute a syntax error. They should be part of your header string but they appear to be just standing by themselves.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    Don't run the values you use in your email through mysql_real_escape_string; that is only for values that you use in a database query to mysql.

    Those extra lines don't actually do anything, but since the syntax is valid it will parse OK. It's effectively a no-op though.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo