Jump to content
Larry Ullman's Book Forums

Recommended Posts

Not sure if this is the right place to ask this question so appologies in advance if I'm off track here. I am using a local server XAMMP to work my way through Larry's book. I have reached "Script 10.1" Sending emails, however the email doesn't go anywhere. Is there some setting in XAMMP to make the email function work. My emails are nothing strange its just "paul@me.com" what I'm saying its not one of those accounts that some local and indeed remote servers do not like.


As a side bar I have the correct script as I posted the page to a remote server and it worked fine, so I know it's not the script. I just thought it would be nice to have all the pages working together on the local server.

Link to post
Share on other sites

Thanks Larry and Jonathon. I followed the link and also looked at other sites for a soloution and they all tell me to do the same thing but it's still not working. I have posted the relavent bit of the php.ini and also the page code. Don't think the code is wrong as the form all works correctly.


[mail function]
XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = mail.me.co.uk

sendmail_from = paul@me.co.uk


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Contact Me</title>
<h1>Contact Us</h1>
<?php # Script 10.1 = email.php
include ('includes/header.html');
// Check for 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 longer than 70 caracters long:
		$body = wordwrap($body, 70);
		// Send the email
		mail('paul@me.co.uk', 'Contact Form Submission', $body, "Form: {$_POST['email']}");
		//Print the message:
		echo '<p style="font-weight: bold; color: red">Thank you for contacting us. We 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 go back and fill out the form correctly.</p>';
} // End of mail isset() IF.

// Now create the HTML form
	<p>Please use this form to contact us.</p>
<form action="email.php" method="post">
<p>Name: <input type="text" name="name" size="30" maxlengh="60" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></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" />
include ('includes/footer.html'); 



; smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = paul@wcrltd.co.uk

Link to post
Share on other sites

Okay, then you need to choose a route. Option A is to get Mercury working in XAMPP. Option B is to configure PHP directly to use your SMTP server. The code you've posted suggests you're trying Option B, not Option A. And, if so, then you need to provide your SMTP auth credentials, too.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...