Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts

    mail() not working properly

    PHP Code:
    <?php 
    $to 
    "west.jamie@gmail.com";
    $subject "Jamie Wests Survey Results";
    $header "from west.jamie@gmail.com 'X-Mailer: PHP/' . phpversion();";
    $message "NAME: {$_POST['firsname']} {$_POST['surname']} DOB:{$_POST['dob']} Year in school: 
    {$_POST['year_school']} siblings: {$_POST['siblings']} bedtime: {$_POST['dob']} homework time: 
    {$_POST['homework']} tv time: {$_POST['tv']} computer time: {$_POST['computer']} 
    family time: {$_POST['family']} time with friends: {$_POST['friends']}"
    ;
    $message wordwrap($message70);
    mail($to$subject$header$message);
    ?>
    it sends me the email, but misses out some of the message, anybody got any idea y?

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    heres the email it sends me :S
    Code:
    4 hours tv time: 2 hours computer time: 6 hours
    family time: 7 hours time with friends: 7hours
    X-MM-Mail-From-Script: /jaysphp/welcome.php
    X-Complains-To: abuse@lycos.co.uk
    X-MM-Mail-From-IP: xxx.xx.xx.x (is acutall IP in here not the *'s)
    Errors-To: jaysphp@lycos.co.uk
    Last edited by rafiki; 08-31-2006 at 08:27 PM.

  • #3
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    you have the wrong argument order for mail()
    http://php.net/mail

    are you trying to include the output from php_version(); in the header? you need to take it outside the string.
    I normally use 'From: email@example.com' (note the colon,, and things work- not saying for sure that's necessary though.
    if you put the arguments in the right order, and skip the additional paramaters (i.e. $header) for now, what happens?

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    took out $headers and still same result, any more ideas?

  • #5
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use This
    $name , $message & $email are values passed from the form on a previous page

    PHP Code:
    <?php
    $emailto 
    "Recipient Address";
    $ToSubject "Subject Here";
    $headers "From: $name <$email>\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"
    $EmailBody "$name - $email<br>";
    $EmailBody .= "sent this message.<br>";
    $EmailBody .= "<br>";
    $EmailBody .= "$message";
    mail($emailto,$ToSubject,$EmailBody,$headers);
    if(
    mail){
    header("Location: thanks.php");
    }
    ?>
    Last edited by managedinternet; 08-31-2006 at 11:53 PM.

  • #6
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any variable with the same name like $message that appears more than once needs a . before =

    example
    PHP Code:
    $message "Hello";
    $message .= "This is my";
    $message .= "Message To You"

  • #7
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    managed thanks for the quick reply, i tried ur solution still didnt send all data, i have fixed it (was typos lol)

  • #8
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no problem


  •  

    Posting Permissions

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