SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot iStudent's Avatar
    Join Date
    Mar 2004
    Location
    So Cal
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't Send Email With The mail() Function

    I am going insane here, for the life of me I can't get this to work. I am trying to use a forum, to send an email, but the mail() function isn't working. The info from the html form page transfers over the php page just fine, but when gets to the mail() function it doesn't do anything. I don't get an error or anything, it just doesn't send.

    PHP Code:

            $school 
    $_POST['school'];
            
    $email $_POST['email'];
            
    $schoolType $_POST['schoolType'];
            
    $track $_POST['track'];
            
    $class $_POST['class'];
            
    $first $_POST['first'];
            
    $last $_POST['last'];
            
    $item $_POST['item'];
            
    $code $_POST['code'];
            
    $discription_string $_POST['discription_string'];
            
            if (
    $school != '' && $email != '' && $schoolType != '' && $track != '' && $class != '' && $first != '' && $last != '' && $item != '' && $code != '' && $discription_string != '')
                {
                    
    $To 'Bob Smith <bobsmith@yahoo.com>';
                    
    $Subject $school;
                    
    $Message $school '<br />' $schoolType $tract '<br />' $first '<br />' $last '<br />' $item '<br />' $code '<br />' $discriptoin_string;
                    
    $headers 'From: ' $school ' <' $email '>\r\n';
                    
    $headers .= "MIME-Version: 1.0\r\n"
                    
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
                
                    
    mail($To,$Subject,$Message,$headers);
                    
                    echo 
    '<h4 align="center">Your message has been sent.</h4>';
                } 

  2. #2
    SitePoint Evangelist Rodney H.'s Avatar
    Join Date
    Sep 2005
    Location
    Chicago, IL
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It appears to be a header problem: You have the first return of your header in single-quotes:

    PHP Code:
    $headers 'From: ' $school ' <' $email '>\r\n'
    but, the return should be in Double Quotes, ("\r\n") :

    PHP Code:
    $headers 'From: ' $school ' <' $email '>' "\r\n"

  3. #3
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    thats the same problem I'm hav'in too
    "Don't you just love it when you solve a programming bug only to create another."

  4. #4
    SitePoint Zealot iStudent's Avatar
    Join Date
    Mar 2004
    Location
    So Cal
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rodney, that was it! Major thanks!!!

  5. #5
    SitePoint Evangelist Rodney H.'s Avatar
    Join Date
    Sep 2005
    Location
    Chicago, IL
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool !!


Bookmarks

Posting Permissions

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