954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

send email from localhost to other email accounts

hi there,
I'm trying to create a function to send email from localhost(postmaster@localhost) to other email accounts(yahoomail,gmail,hotmail).I'm currently using xampp and the mercury32 inside xampp.I had successfully sent email from localhost to localhost but I can't make it to send outside from localhost. This is the code and it works perfectly sending email from localhost to localhost.

<?php

//Check whether the submission is made
if(isset($_POST['Submit'])){

//Declarate the necessary variables
$mail_to=$txtEmailto2;
$mail_from=$txtEmailfrm2;
$mail_sub=$txtSub2;
$mail_mesg=$txtMsg;

//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from"))
echo "<span class='red'>E-mail has been sent successfully from $mail_to to $mail_from</span>";
else
echo "<span class='red'>Failed to send the E-mail from $mail_to to $mail_from</span>";
}
?>
<html>
<body>
<form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()">
      <table width="100%"  border="0">
        <tr>
         <td width="33%" align="right" class="text">To :
          <td width="67%"><input name="txtEmailto2" type="text" class="input" id="txtEmailto22" size="30" maxlength="100">
        </tr>
        <tr>
          <td align="right" class="text">From :
          <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100">
        </tr>
        <tr>
          <td align="right" class="text">Subject :
        <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100">
        </tr>
        <tr>
          <td align="right" class="text">Mesage(body) :
         <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea>
        </tr>
      <tr>
          <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true">
              <input name="Submit" type="submit" class="input" value="Send">
          <td><input name="Submit2" type="reset" class="input" value="Reset">
        </tr>        
      </table>
     </form>
               
</body>
</html>
littlebear330
Newbie Poster
5 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

Im not sure but I think you cant send mail from a home made server like apache, etc.

I guess if you wanted to you might have to hand out some cash and make your localhost a full fledge server, which you may or may not be inclined on doing.

OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
 

Do you need an smtp server to send mail? Otherwise, I think Joe Jobbing would be the norm.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

Im not sure but I think you cant send mail from a home made server like apache, etc.

I guess if you wanted to you might have to hand out some cash and make your localhost a full fledge server, which you may or may not be inclined on doing.

All you need is to set up an SMTP server. Most linux distros come with 'sendmail' installed which is probably the most popular. I have no idea how to do it in Windows.

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

Grew up on windows need to start showing some love to unix :|

But if he made his computer a SMTP that would mean his computer would have to be on everytime the website required to send it?

So if its just for self use it is fine, but if it was meant to be a 24/7 thing he would have to keep his computer on?

Also where would get a SMTP?

OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
 

check this site, here you can send email to any account using your gmail username and password from localhost.

http://arunss.wordpress.com/2009/12/09/sending-email-from-localhost-using-php/

arunss
Light Poster
30 posts since Dec 2009
Reputation Points: 10
Solved Threads: 3
 
$to = "Your gmail id";
$from = "yahoo id";
$subject = "Success msg";
$sendmail = @mail($to,$subject,$body,"From: $from\nContent-Type: text/html; charset=iso-8859-1");


When you use xampp and mercury
1> Start xampp and mercury do not close mercury window.To get mail from local to mail i.e (yahoo,gmail)
it take long time duration...may be it come in spam

Aamit
Posting Whiz
342 posts since Apr 2008
Reputation Points: 3
Solved Threads: 15
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You