Results 1 to 3 of 3

Thread: PHP Email Testing using XAMPP

  1. #1
    Join Date
    Nov 2007
    Location
    USA
    Posts
    170
    Thanks
    8
    Thanked 22 Times in 22 Posts

    Default PHP Email Testing using XAMPP

    ok so I am using XAMPP and trying to send an email to myself here is my code:

    PHP Code:
    <?php
    $name 
    $_POST['name'];
    $email $_POST['email'];
    $body $_POST['body'];
    if (
    $name != "" AND $email != "" AND $body != "") {
    //PUT YOUE EMAIL ADDRESS -----
    $sendto "myemail@blah.com"
    //PUT YOUR EMAIL ADDRESS -----
    $subject "Email from site!"

    $message "This is a message from your site
    From: 
    $name 
    Email: 
    $email 
    Message: 
    $body"
    // send the mail
    mail("$sendto""$subject""$message","mosh");
    echo 
    "Your message was sent";
    }
    ?><form method="post" name="mailform" action="<?=$_SERVER['PHP_SELF'?>">

    <table width="200"  border="0" cellspacing="0">
      <tr>
        <td width="62">Name:</td>
        <td width="134">
          <input name="name" type="text" id="name">
       </td>
      </tr>
      <tr>
        <td>Email:</td>
        <td><input name="email" type="text" id="email"></td>
      </tr>
      <tr>
        <td valign="top">Message:</td>
        <td><textarea name="body" cols="45" rows="10"></textarea></td>
      </tr>
    </table> 
      <br>
      <input type="submit" name="Submit" value="Submit">
      <input type="reset" name="Submit2" value="Reset">
    </form>
    I dont think there is anything wrong with the code snippet because i got it from a reliable source: http://www.dreamincode.net/code/browse.php?cid=1

    but here is the error i keep getting when i try to run it:

    Code:
    Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in
    I tried messing with the php.ini file but that got me no where (probably cuz i have no idea what to do with it)

    Any help with this problem would be very appreciated. Thank You in advance!

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I'm no whiz with the mail() function. But Its because in php.ini, around line 753. You've got a variable called "sendmail_from", its probably set to "localhost", give that an email. For example. My email is jeremyfifty9 [at] gmail [dot] com. SO I'd put that in. Below is an attachment of what the line probably is defaulted to.
    Also just to make your code a bit shorter, you can change:
    Code:
    if ($name != "" AND $email != "" AND $body != "") {
    To
    Code:
    if ($name != "" && $email != "" && $body != "") {
    And:
    Code:
    mail("$sendto", "$subject", "$message","mosh");
    To:
    Code:
    mail($sendto,$subject,$message,mosh);
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2008
    Location
    Estados Unidos
    Posts
    26
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    I use xampp also on a vista box. You need to install a mail server, and depending on your isp there are different configurations.


    Edit:
    I thought about it some more and remember a little more about when I installed xampp.

    If you're just using it for local development like me and are not hosting a site then you'll need an e-mail address. That's were it depends on your isp. You can configure it to work with a free web mail service but gmail is the only one that I remember. Yahoo is a no go. I'm a noob so hopefully my recollection will aid others in helping you resolve your problem.

    Good luck,
    Joe
    Last edited by jeaux; 08-22-2008 at 01:00 AM.

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
  •