CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Jul 2009
    Posts
    6

    Unhappy problem in sending mail through mail function in php

    I made file one is html that is

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html>
    <head><title>Mail sender</title></head>
    <body>
    <form action="mail.php" method="POST">
    <b>Email</b><br>
    <input type="text" name="email" size=40>
    <p><b>Subject</b><br>
    <input type="text" name="subject" size=40>
    <p><b>Message</b><br>
    <textarea cols=40 rows=10 name="message"></textarea>
    <p><input type="submit" value=" Send ">
    </form>
    </body>
    </html>
    and one for php for sending mail that is


    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head><title>PHP Mail Sender</title></head>
    <body>
    <?php

    /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
    $email $HTTP_POST_VARS['email'];
    $subject $HTTP_POST_VARS['subject'];
    $message $HTTP_POST_VARS['message'];

    /* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
    if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/"$email)) {
      echo 
    "<h4>Invalid email address</h4>";
      echo 
    "<a href='javascript:history.back(1);'>Back</a>";
    } elseif (
    $subject == "") {
      echo 
    "<h4>No subject</h4>";
      echo 
    "<a href='javascript:history.back(1);'>Back</a>";
    }

    /* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
    elseif (mail$email,$subject,$message,"hhh")) {
      echo 
    "<h4>Thank you for sending email</h4>";
    } else {
      echo 
    "<h4>Can't send email to $email</h4>";
    }
    ?>
    </body>
    </html>
    and when i run this through html form it through this error

    Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in e:\amit\wamp\www\pp\mail.php on line 22

    Can't send email to [email protected]
    i can i get any solution plz help me out
    as soon as possible
    Last edited by PeejAvery; July 30th, 2009 at 08:45 AM. Reason: Added code and PHP tags.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured