I have my file mail.php :
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("syedsamiruddin29@gmail.com", $subject,
$message, "From:" . $email);
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mail.php'>
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' />
</form>";
}
?>
</body>
</html>
but when i run it. i get this error :
Warning: mail() [function.mail]: Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\EasyPHP-5.3.8.1\www\safepay247\mail.php on line 13
Thank you for using our mail form
what im trying to do is to send an email to my email id : syedsamiruddin29@gmail.com using php to the person's email written in the input type.
Ive gone through many videos but none help me solve the php.ini problem.
You need to set up your SMTP server in your php.ini
.
The directives you need to change are listed here. The settings should be provided by your hosting provider.
But before we get ahead of ourselves, just a quick warning:
You are sending the email by masquerading as someone else by setting the Email in the "from" header.
Most SMTP server would require some form of authentication, for example to send something using the gmail SMTP server, I would need to authenticate with my username and password.
If the email in the form field does not match the authentication username, it could be rejected by the server, or it could be changed to reflect the authentication username. Finally, it might not play well with spam filters.
My suggestion is that you send the email from one of your own email accounts, for example (customerenquiry@yourdomain.com). Then in the body of the message, put in the customer's email address. You can also set the reply-to
header to the customer's email address, so that clicking "reply to" in your email client would automatically put their email address in the "to" field.
Try this:
Open the php.ini
.
Search for the attribute called SMTP
in the php.ini file. Generally you can find the line SMTP=localhost
. change the localhost to the smtp server name of your ISP. And the set the port of 25.
SMTP = smtp.gmail.com #user your smtp address here
smtp_port = 25
Restart the apache server or wamp or xammp. Whatever you are using.
Now try to send the mail using the mail() function