Today I am going to post something through which you can send emails from localhost without using any 3rd party tool like
Microsoft Outlook,thunderbird etc or any other service provided by gmail,yahoo mail etc
Required Software
1:-Web browser (any)
2:-XAMPP server ,you can search on net or ask me for this ,it is open source ,you can easily get it
Now let us do some coding
First of all let us create simple html file with name sendmail.htm
<html>
<body>
<form action='mail.php' method='post'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br/>
<input type='submit' name='send' value='send'/>
</form>
<body>
<html>
Now create a simple file mail.php
<?php
if ($_REQUEST['send']=='send')
{
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("goyalmanish47@gmail.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
?>
Here if when you try to execute this file then you will get warning message thus your email will not be sent
So now for this purpose you have to perform some settings
so first locate file named php.ini in xampp directory
You will find the following lines change it exactly in the same way i have written below
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = smtp.gmail.com
; http://php.net/smtp-port
;smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
Now you have to perform some downloading
Downloading sendmail.zip file form following link
Download from here
Now extract all the file from this zip file copied all those files in sendmail directory inside xampp
Note:-Replace files if some files already exist
now locate file sendmail.ini and overwrite the whole file with following text(write required things like username and password)
as i have written below
///////////////
[sendmail]
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=write user name of your gmail id
auth_password=write your password
force_sender=You id here
//////////////////////////
Now save this file as sendmail.ini
That's it
Now restart xampp
You can now send emails from localhost