Sending email localy

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

Sending email localy

Postby Paulst » 23. August 2012 11:32

Could anyone help please? I am trying to develop a website on my local machine and I can't seem to get the email function working localy. The script works fine using a remote server but won't work localy. I have configured the php.ini file as per instructions and the same with sendmail.ini. When I fill out the form it returns email sent successfully but it doesn't go anyware. I have attached 1, the script, 2, the mail function section of the php.ini file and the sendmail.ini. I have tried it quoted and unquoted. Any help would be apreciated.

I have changed email addresses to avoid spam.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Me</title>
<h1>Contact Me</h1>
<?php # Script 10.1 - email.php
// Check the form submission:
if (isset($_POST['submitted'])) {

// Minimal form 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 caracters long:
$body = wordwrap($body, 70);

// Send the mail:
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 forms not sticky):
$_POST = array();

} else {
echo '<p style="font-weight: bold; Color: #c00">Please fill out the form completley.</p>';

} // End of main isset() IF.
// Create the HTML form
<p>Please fill out this form to contact me.</p>
<form action="mail.php" method="post">
<p>Name: <input type="text" name="name" size="30" maxlengh="60" value="<?php if (isset($_POST['name'])) echo $_post['email']; ?>" /></p>
<p>Email Address: <input type="text" name="email" size="30" maxlengh="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>
<input type="hidden" name="submitted" value="TRUE" />

[mail function]
XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
smtp_port = 25

For Win32 only.
sendmail_from =

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.

; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\php\logs\php_mail.log"

sql.safe_mode = Off

; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail


; you must change to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

; smtp port (normally 25)


; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL


; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify


; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging


; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging


; if your smtp server requires authentication, modify the following two lines

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content


; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content


; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required

Posts: 1
Joined: 23. August 2012 10:38
Operating System: Windows 7

Re: Sending email localy

Postby JonB » 24. August 2012 14:26

If you want to be able to receive mail locally you will have to set up a local mailserver.

If you only want to validate that the mail is sent, use mailtodisk.

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 79 guests