Problem With Sending Email Through PHP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Problem With Sending Email Through PHP

Postby michaelli321 » 23. August 2011 18:45

I created a form that was supposed to send an email to me, but I get this error:

Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\email.php on line 25

Here is my code:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" xml:lang="en" lang="en">
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>Contact Me</title>
    <h1>Contact Me</h1>
    <?php # Script 10.1 - email.php
    // Check for form submission:
    if (isset($_POST['submitted'])) {
        // Minimal for validation:
        if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments']) ) {
            // Create the body:
            $body = "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}";
            // Make it no longer than 70 characters long:
            $body = wordwrap($body, 70);
            // Send the email:
            mail('', 'Contact Form Submission', $body, "From: {$_POST['email']}");
            // Print a message:
            echo '<p><em>Thank you for contacting me. I will reply some day.</em></p>';
            // Clear $_POST (so that the form's not sticky):
            $_POST = array();
        } else {
            echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>';
    } // End of main isset() IF.
    // Create the HTML form:
    <p>Please fill out this form to contact me.</p>
    <form action="email.php" method="post">
        <p>Name: <input type="text" name="name" size="30" maxlength="60" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p>
        <p>Email Address: <input type="text" name="email" size="30" maxlength="80" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>
        <p>Comments: <textarea name="comments" rows="5" cols="30"><?php if (isset($_POST['comments'])) echo $_POST['comments']; ?></textarea></p>
        <p><input type="submit" name="submit" value="Send!" /></p>
        <p><input type="hidden" name="submitted" value="TRUE" />

I'm not sure if I need to download something else, or configure php.ini or what. Any help?
Posts: 1
Joined: 23. August 2011 18:42

Re: Problem With Sending Email Through PHP

Postby JonB » 23. August 2011 19:27

You probably need to configure both PHP and Sendmail (assuming you did not do so already)

try looking at this: ... or-windows

Good Luck

User avatar
AF Moderator
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 51 guests