php mail function error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michaeldebruin
    New Member
    • Feb 2011
    • 134

    php mail function error

    Hello,

    I am trying to create a mail function for my contact form and for my registration system.
    But I repeatedly getting the same error:

    Warning: mail() [function.mail]: "sendmail_f rom" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs \website\actie. php on line 21

    I've already searched for solutions on google, but I couldn't find one which solved my problem.

    the things I've tried to change:
    smtp in php.ini and the sendmail_from (none of the php.ini files found in xampp/php/php.ini changed a value in the phpinfo)
    mercury mail server from xampp activated.

    the code for my contact form is split up in 2 php files with the following code

    contact.php
    Code:
    <form method="POST" action="actie.php"><br>
    					Name:<br><input type="text" name="naam" size="50"><br>
    					E-mail:<br><input type="text" name="email" size="50"></select><br>
    					Subject:<br><input type="text" name="subject" size="50"></select><br>
    					Tekst:<br><textarea rows="3" name="tekst" cols="75"></textarea>
    					<br><input type="submit" name="verzend" value="Verzenden">
    action.php
    Code:
    $ontvanger = "my email@address.com";
    $onderwerp = "Iemand heeft je formulier ingevuld";
    
    // We definiƫren vervolgens de veranderlijke variabelen.
    $naam = $_POST['naam'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $tekst = $_POST['tekst'];
    $headers= 'To: <michael.bruin@live.nl>' . "\r\n";
    // Bericht
    
    $bericht = "Iemand heeft je contactformulier ingevuld.\nHet gaat om '".$naam."', met het e-mailadres '".$email."', wonende in '".$subject."'. Hij vulde de volgende opmerking in:\n'".$tekst."'";
    $tekst = str_replace("\n.", "\n..", $tekst);
    
    // Verzenden
    mail($ontvanger, $onderwerp, $bericht, $headers);
    
    // Bericht verzonden
    
    echo "Uw bericht werd verzonden.";
    and the part of my registration file which won't send the mail:
    Code:
    $mail = mail($_POST['email'],"Registratie ".$sitenaam,$bericht,"From: ".$sitenaam." <".$sitemail.">");
    thanks for reading and many thanks if you can help me with this problem.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    as said in the error message (and of course in the Manual), you need a From: header field. (that concerns the first code, line #16)

    Comment

    • Rekha Kumaran
      New Member
      • Jan 2011
      • 30

      #3
      I too facing the same prob... Help me...

      Comment

      • michaeldebruin
        New Member
        • Feb 2011
        • 134

        #4
        The problem is solved for me. I had the problem that the mail function wasn't enabled in my php.ini. And I couldn't find the right php.ini thanks to the fact that I somehow had 3 php.ini and none of them could make any difference to my phpinfo. But now that my website is online and I have an email account on it, I am enable to send emails with the php code which is displayed above. I also used the tip of Dormilich to dubble check my "From:" header and changed it a bit.

        Comment

        • Rekha Kumaran
          New Member
          • Jan 2011
          • 30

          #5
          Will u plz explain me how to enable mail function in php.ini?

          Comment

          • michaeldebruin
            New Member
            • Feb 2011
            • 134

            #6
            you will have to search in php.ini for mail function and then at smtp the smtp of your provider. To give an example the email acount from my website is his own provider which makes it mail.it-traffic.com. Afther that you will have to set the port, this is mostly port 25. Then check if your phpinfo at mail function is correct. If it is correct you should be able to send a mail with your php script. Ofcourse you will have to all the headers and stuff like that to your wishes: http://nl.php.net/manual/en/function.mail.php
            This site can help you with that the php mail function

            Comment

            Working...