Paul_Blackpool Posted January 29, 2013 Share Posted January 29, 2013 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 comment Share on other sites More sharing options...
Larry Posted January 29, 2013 Share Posted January 29, 2013 Yes, you need to configure XAMPP to send emails. If you Google "send email xampp", you'll find lots of links on how to do this. Link to comment Share on other sites More sharing options...
Jonathon Posted January 29, 2013 Share Posted January 29, 2013 http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html I put this on here some time ago, but I couldn't find it. But it was pretty good at getting emails up for me and I know a few others here have sued it too. 1 Link to comment Share on other sites More sharing options...
Paul_Blackpool Posted January 31, 2013 Author Share Posted January 31, 2013 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 MercurySMTP = 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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact Me</title> </head> <body> <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" /> </form> <?php include ('includes/footer.html'); ?> </body> </html> ; smtp_port = 25 ; For Win32 only.; http://php.net/sendmail-fromsendmail_from = paul@wcrltd.co.uk Link to comment Share on other sites More sharing options...
Larry Posted February 1, 2013 Share Posted February 1, 2013 Does your ISP require authentication to send out emails? Link to comment Share on other sites More sharing options...
Paul_Blackpool Posted February 1, 2013 Author Share Posted February 1, 2013 Yes it does Larry Link to comment Share on other sites More sharing options...
Larry Posted February 1, 2013 Share Posted February 1, 2013 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 comment Share on other sites More sharing options...
Paul_Blackpool Posted February 2, 2013 Author Share Posted February 2, 2013 Thanks Larry I started Mercury in the xammp control panel and it worked fine Link to comment Share on other sites More sharing options...
Larry Posted February 2, 2013 Share Posted February 2, 2013 Glad to hear it. Thanks for letting us know. Link to comment Share on other sites More sharing options...
Recommended Posts