Click here to Skip to main content
15,888,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to send mail by using core php code but its not working and errors are not displayed on screen.Getting output of mail sent but in actual mail is not getting sent.
below is the code.pls help me how can i send mail through this code


if(isset($_REQUEST['send']))
{
$t=$_POST['to'];
$s=$_POST['subject'];
$b=$_POST['body'];
if(mail($t,$s,$b))
{
echo "mail sent";
}
else
{
echo "mail not sent";
}
}
?>

<html>

Sending mail


<body>
<form>

to<input type="text" name="to" />
subject<input type="text" name="subject" />
body<input type="text" name="body" />
<input type="submit" name="send" value="send" />
</form></body></html>

below are the changes made in php.ini file
CSS
[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 = kakminder@gmail.com
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"


here is the changes made in sendmail.php
# Example for a user configuration file

# Set default values for all following accounts.
defaults
logfile "D:\xampp\sendmail\sendmail.log"

#Mercury
#account Mercury
#host localhost
#from postmaster@localhost
#auth off


#A freemail service example
#account Hotmail
#tls on
#tls_certcheck off
#host smtp.live.com
#from [exampleuser]@hotmail.com
#auth on
#user [exampleuser]@hotmail.com
#password [examplepassword]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=kakminder@gmail.com
auth_password=9816537569
force_sender=kakminder@gmail.com

# Set a default account
account default : Gmail
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900