How to send an mail from the website ..? I am using html and php for my static website but it is not senting an mail through xamp server.... my php code is
<?php
$to = "my@domain.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "from@domain.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
but it is not sending an email..
can anyone help me..?
It is more likely that you are trying to send mail using your local machine. You could try the following:
php.ini
. You should know where it is located because it depends upon the particular server you're running. 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, there is another attribute called smtp_port
which should be set to 25
. Eg in your php.ini file:
SMTP = smtp.mylink.com.np smtp_port = 25
Restart the apache server so that PHP modules and attributes will be reloaded.
Now try to send the mail using the mail()
function
mail("you@yourdomain.com","test subject","test body");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.