简体   繁体   中英

Mails from PHP on XAMPP not being sent

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:

  1. Open the php.ini . You should know where it is located because it depends upon the particular server you're running.
  2. 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 
  3. Restart the apache server so that PHP modules and attributes will be reloaded.

  4. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM