FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Sending Email from localhost





imagefree
i want to send email from localhost to my email address(es). Email addresses may be at gmail, yahoo or frihost.


Can you tell me how to do it? I am using php for this, but an error occurs.
Also i am using XAMPP.

Please help me in doing so.

Thanks
rvec
http://nl2.php.net/manual/en/function.mail.php

that should always work. If it doesn't something is wrong with your installation.
imagefree
This is the error message .

Code:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs\php\functions.php on line 117

(This php\ directory is mine (not of the server).

Here are extracts from php.ini:


Code:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "D:\xampp\sendmail\sendmail.exe -t"

; 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 =


Is something missing?

Here is the message:

Code:
$mail_body="<html>
   <body>
   <p>Congratulations! Your Account is Created at Example.<br></p>
   <p>Please click <a href=\"http://www.example.com/verify.php?id=$verification\">here</a> to varify your Email Address or simply copy<br>
   http://www.example.com/verify.php?id=$verification</p>
   </body>
   </html>";

mail($email,"Exmple.com Account Varification",$mail_body,"From: praisedpk@gmail.com");
jeremyp
imagefree wrote:
This is the error message .

Code:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs\php\functions.php on line 117

(This php\ directory is mine (not of the server).

Is something missing?


Yes.

An SMTP server. There isn't one running on localhost judging by the error message.
imagefree
what should i do?
rvec
I think you should reinstall XAMPP
Agent ME
Install a mailserver - I think XAMPP includes one.

Note that some email providers may auto-block emails from a standard DSL/cable/dial-up line as mostly spam emails come from those.
pollux1er
Try to download one to be more sure of it.
rvec
XAMPP includes one. No need to install another one. Reinstalling XAMPP will most likely solve the problem.
Stubru Freak
Or you could set SMTP to your ISP mail server, or a public one like Yahoo.
AOP Web Development
for xampp, i know that there is a mail server include mercury Mail i think.. all you need is to run the application and try to set up a localhost host email in your outlook express.. that pointing to webmaster@localhost and you can now start sending via localhost for testing..
mehulved
Maybe you just need to start mercury mail server from xampp page?
imagefree
i tried the following things:

Code:

#php.ini
extension=php_smtp.dll

enabled it.

Code:

#php.ini
SMTP = localhost
smtp_port = 25
sendmail_path = "D:\xampp\sendmail\sendmail.exe -t"


i have xampp running perfectly, and running Mercury mail on it.

When i send email using password varification script ( on LOCALHOST) an information box opens (for just about tenth of a second) and the script says that email is successfully sent. But i am not receiving email on my Gmail inbox.
What may be the problem?
(I was Googling the same problem and i found my this thread there in top Very Happy .)
rafaelcarioca7
tutorial teaching how configure php to send email localhost
http://rafaelcarioca7.blogspot.com.br/2012/03/configurar-php-para-enviar-email-local.html
D'Artagnan
you can use phpmailer http://phpmailer.worxware.com/ and configure an SMTP , so you can send emails from localhost using any email provider, such as gmails

see:

http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/
chaddelange
imagefree wrote:
i want to send email from localhost to my email address(es). Email addresses may be at gmail, yahoo or frihost.


Can you tell me how to do it? I am using php for this, but an error occurs.
Also i am using XAMPP.

Please help me in doing so.

Thanks


Hello, You can try this http://www.mailforlocalhost.cixx6.com
thlastbreath
Hi all,

I am currently having problems in connecting to the local host database. I can't see anything upon the completion of my form. Can anyone help?

Codes for my php:







<?php
$con = mysql_connect("localhost","- Lenovo -","123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_registration("registration", $con);

$sql="INSERT INTO Registration (FirstName, LastName, Address, Address Line 2, City, State, Posstal, Country, Email, Phone, Workshop Selected, Referral)
VALUES
('$_POST[element_2]','$_POST[element_3]','$_POST[element_6]','$_POST[element_7]','$_POST[element_8]','$_POST[element_9]','$_POST[element_10]','$_POST[element_11]','$_POST[element_13]','$_POST[element_14]','$_POST[element_16[]]','$_POST[element18]')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con);
?>


Quote:


Codes for my form:

<form id="emf-form" enctype="multipart/form-data" method="post" action="process.php">
<table style="text-align:left;" cellpadding="2" cellspacing="0" border="0" bgcolor="#FFFFFF">
<tr>
<td style="" colspan="2">
<font face="Verdana" size="2" color="#000000"><b style="font-size:20px;">Workshop Registration</b><br />
<br /></font>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_0" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Name</b></font></td>
<td id="td_element_field_0" style="">
<div style="padding-bottom:8px;color:#FFFFFF;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_2" style="" align="center">
<font face="Verdana" size="2" color="#000000"><b>First</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_2" style="">
<input id="element_2" name="element_2" value="" size="30" class="validate[required]" type="text" />
<div style="padding-bottom:8px;color:#ffffff;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_3" style="" align="center">
<font face="Verdana" size="2" color="#000000"><b>Last</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_3" style="">
<input id="element_3" name="element_3" value="" size="30" class="validate[required]" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_6" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b> Address</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_6" style="">
<input id="element_6" name="element_6" value="" size="30" class="validate[required]" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_7" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Address Line 2</b></font>
</td>
<td id="td_element_field_7" style="">
<input id="element_7" name="element_7" value="" size="30" class="validate[optional]" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_8" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>City</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_8" style="">
<input id="element_8" name="element_8" value="" size="30" class="validate[required]" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_9" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>State / Province / Region</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_9" style="">
<input id="element_9" name="element_9" value="" size="30" class="validate[required]" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_10" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Postal / Zip Code</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_10" style="">
<input id="element_10" name="element_10" value="" size="30" class="validate[required]" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_11" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Country</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_11" style="">
<input id="element_11" name="element_11" value="" size="30" class="validate[required]" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td colspan="2" style="">
<h3 style="font-size:14px;padding:10px 0 6px 0;border-top:1px dotted #CCCCCC;margin:14px 0;position:static;" id="element_12" name="element_12">
<font face="Verdana" size="2" color="#000000">Personal Information</font>
</h3>
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_13" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Email</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_13" style="">
<input id="element_13" name="element_13" class="validate[required,custom[email]]" value="" size="30" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Confirm</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td style="">
<input id="element_13_confirm" class="validate[confirm[element_13]]" value="" size="30" type="text" onpaste="return false;" />
</td>
</tr>
<tr valign="top">
<td id="td_element_label_14" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Phone</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_14" style="">
<input id="element_14" name="element_14" class="validate[required,custom[telephone]]" value="" size="30" type="text" />
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td colspan="2" style="">
<h3 style="font-size:14px;padding:10px 0 6px 0;border-top:1px dotted #CCCCCC;margin:14px 0;position:static;" id="element_15" name="element_15">
<font face="Verdana" size="2" color="#000000">Workshop Selection</font>
</h3>
<div style="padding-bottom:8px;color:#000000;">
<small><font face="Verdana">Please select the workshops you would like to attend. Check all that apply.</font></small>
</div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_16" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Select Workshop</b></font> <span style="color:red;"><small>*</small></span>
</td>
<td id="td_element_field_16" style="">
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_0" name="element_16[]" value="Chinese" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Chinese&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_1" name="element_16[]" value="Danish" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Danish&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_2" name="element_16[]" value="Thai" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Thai&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_3" name="element_16[]" value="French" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;French&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_4" name="element_16[]" value="German" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;German&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_5" name="element_16[]" value="Greek" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Greek&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_6" name="element_16[]" value="Irish" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Irish&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_7" name="element_16[]" value="Italian" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Italian&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_8" name="element_16[]" value="Japanese" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Japanese&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_9" name="element_16[]" value="Korean" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Korean&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_10" name="element_16[]" value="Latin" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Latin&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_11" name="element_16[]" value="Romanian" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Romanian&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_12" name="element_16[]" value="Russian" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Russian&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_13" name="element_16[]" value="Spanish" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Spanish&nbsp;</font>
</div>
<div style="float:left;width:50%;padding-bottom:5px;">
<input id="element_16_14" name="element_16[]" value="Turkish" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000">&nbsp;Turkish&nbsp;</font>
</div>
<div style="clear:both;"></div>
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr valign="top">
<td colspan="2" style="">
<h3 style="font-size:14px;padding:10px 0 6px 0;border-top:1px dotted #CCCCCC;margin:14px 0;position:static;" id="element_17" name="element_17">
<font face="Verdana" size="2" color="#000000">Referral Information</font>
</h3>
<div style="padding-bottom:8px;color:#000000;">
<small><font face="Verdana">How did you find out about this workshop?</font></small>
</div>
</td>
</tr>
<tr valign="top">
<td id="td_element_label_18" style="" align="left">
<font face="Verdana" size="2" color="#000000"><b>Referral</b></font>
</td>
<td id="td_element_field_18" style="">
<div style="width:100%;padding-bottom:5px;">
<input id="element_18_0" name="element_18" value="Google" class="validate[optional]" type="radio" /><font face="Verdana" size="2" color="#000000">&nbsp;Google&nbsp;</font>
</div>
<div style="width:100%;padding-bottom:5px;">
<input id="element_18_1" name="element_18" value="Bing" class="validate[optional]" type="radio" /><font face="Verdana" size="2" color="#000000">&nbsp;Bing&nbsp;</font>
</div>
<div style="width:100%;padding-bottom:5px;">
<input id="element_18_2" name="element_18" value="Yahoo" class="validate[optional]" type="radio" /><font face="Verdana" size="2" color="#000000">&nbsp;Yahoo&nbsp;</font>
</div>
<div style="width:100%;padding-bottom:5px;">
<input id="element_18_3" name="element_18" value="Friend or Colleague" class="validate[optional]" type="radio" /><font face="Verdana" size="2" color="#000000">&nbsp;Friend or
Colleague&nbsp;</font>
</div>
<div style="width:100%;padding-bottom:5px;">
<input id="element_18_4" name="element_18" value="Advertisement" class="validate[optional]" type="radio" /><font face="Verdana" size="2" color="#000000">&nbsp;Advertisement&nbsp;</font>
</div>
<div style="width:100%;padding-bottom:5px;">
<input id="element_18_5" name="element_18" value="Other (please specify)" class="validate[optional]" type="radio" /><font face="Verdana" size="2" color="#000000">&nbsp;Other (please
specify)&nbsp;</font><br />
<input style="margin-left:20px;" type="text" onclick="document.getElementById('element_18_5').checked = 'checked';" onchange="document.getElementById('element_18_5').value = this.value;"
name="element_18_other" value="" />
</div>
<div style="clear:both;"></div>
<div style="padding-bottom:8px;color:#000000;"></div>
</td>
</tr>
<tr>
<td colspan="2">
<script type="text/javascript">
//<![CDATA[
var RecaptchaOptions = {
theme: 'clean',
custom_theme_widget: 'emf-recaptcha_widget'
};
//]]>
</script> <script type="text/javascript" src="https://www.google.com/recaptcha/api/challenge?k=6LchicQSAAAAAGksQmNaDZMw3aQITPqZEsX77lT9">
</script> <noscript><iframe src="https://www.google.com/recaptcha/api/noscript?k=6LchicQSAAAAAGksQmNaDZMw3aQITPqZEsX77lT9" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge" /></noscript>
</td>
</tr>
<tr>
<td colspan="2" align="left">
<input name="element_counts" value="19" type="hidden" /> <input name="embed" value="forms" type="hidden" /><input value="Register" type="submit" />
</td>
</tr>
</table>
</form>

nepalstar
Sending mail from local host is really good Idea... I'm also going to try this..! Thanks for the conversation above...! Hope I got any problem you guys will help me...!
radhika
I'm using joomla 2.5 to create a web page..i want to send email from local host to some other accounts like gmail,ymail...,i tried some php code but im not getting result...can u give idea... and im using WAMP
futurcat
Using wordpress plugins is the easiest.
metalfreek
This is exactly what I was looking for but I cannot see the sure method that would work. I have been changing php.ini setting of XAMPP but I am still unable to send email from localhost. If you solve this problem please post here the solution.
futurcat
metalfreek wrote:
This is exactly what I was looking for but I cannot see the sure method that would work. I have been changing php.ini setting of XAMPP but I am still unable to send email from localhost. If you solve this problem please post here the solution.


what is the error you get in XAMPP?
metalfreek
futurcat wrote:
metalfreek wrote:
This is exactly what I was looking for but I cannot see the sure method that would work. I have been changing php.ini setting of XAMPP but I am still unable to send email from localhost. If you solve this problem please post here the solution.


what is the error you get in XAMPP?


Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

This is the error I am getting.
metalfreek
After trying for countless number of times, I have finally succeed in sending mail from localhost.
I am using XAMPP. Here is the process.

1. Open php.ini with text editor of your choice.
2. Find SMTP, by default the value looks like this SMTP = localhost
3. Change localhost to your internet service provider SMTP address. Generally this adddress looks like this: smtp.your-isp.com
4. Make sure that SMTP port is 25 ( smtp_port = 25 )
5. Save php.ini file and restart XAMPP.

This should have solved the problem but some mail never went to my inbox so after some time searching for the problem I have found that you have to attach header information to your mail like this:

$headers = "From:<$email>\r\n".
"X-Mailer: PHP/" . phpversion() . "\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
"Content-Transfer-Encoding: 8bit\n";


I am sure you guys know how to use php mail function but mine looks like this

mail($adminaddress, $subject, $message, $headers)

This solved my problem let me know if you still have some trouble.
xpcpro
Make sure your port is the same. Mercury is running. Headers are included. And the code above looks fine. You should be on your way to sending a message!
prasadcool
Also you can configure some smtp settings of any site from the host on your local machine

imagefree wrote:
i want to send email from localhost to my email address(es). Email addresses may be at gmail, yahoo or frihost.


Can you tell me how to do it? I am using php for this, but an error occurs.
Also i am using XAMPP.

Please help me in doing so.

Thanks
Related topics
What do most of you do when you are online?
SendMail Script
how to make web hosting
formularios y correo-e, !ayuda¡
cool sms addon
Is it a Virus?!?!
No mail sending on Outlook 2003
Sending email via PHP
Hide addresses in Outlook
sending email to multiple users.
Response I get because I Don't want email service?
Multiple email Addresses
DEBUG MODE?
php mail function not sending email to Yahoo address
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.