Download AMPPS

Subscribe to our Newsletter for any and all AMPPS related news and tutorials
By entering your email, you agree to our Terms of Service and Privacy Policy.

Tell your Friends about AMPPS


How to Send Email from localhost on Windows

Install Sendmail 

  • To install Sendmail go to AMPPS -> Install Apps section.
  • Now go to Utilities and click install button next to the sendmail section and wait until the installation completes.
  • After sendmail is installed we will proceed with configuring sendmail.

 

Configure sendmail.ini file

 

  • Now go to path\to\Ampps\sendmail\ and open sendmail.ini file and make changes as explained below and save the file.
  • Replace the smtp server, port username and password values with the actual ones.

 

        ;Configure Sendmail


        [sendmail]


        smtp_server=<server>


        smtp_port=<port>


        auth_username=<authentication username OR sender_email@gmail.com >


        auth_password=<authentication password OR sender_email_password>

 

    Configure php.ini file

     

    • For configuring php.ini file go to AMPPS panel click Settings button next to the php version and click Configuration button and open PHP conf file, make following changes and save the file.
    • Comment out the smtp configuration settings in php.ini as we have already set the correct values in sendmail.ini
    • Set the sendmail_path correctly as per the login where AMPPS is installed on your PC.
    • After complete the changes in php.ini file restart apache .

     

            ;SMTP = localhost;


            ;smtp_port = <port>;


            ;auth_username = ;


            ;auth_password = ;


            ;sendmail_from = me@example.com


            sendmail_path = path\to\Ampps\sendmail\sendmail.exe

     

    Test the Email

     

    • In this step, we will write the PHP program to send email using the configurations done by us in previous steps.
    • Create test.php file at path\to\Ampps\www  and write following code into test.php file.
    • Change the sender and receiver email with the actual ones.

     

            <?php


            $from = "sender_email@gmail.com";


            $to = "receiver_email@gmail.com";


            $subject = "Hello Sendmail.";


            $message = "This is an test email to test Sendmail.";


            $headers = [ "From: $from" ];


            mail( $to, $subject, $message, implode( '\r\n', $headers ) ); 

     

     

    • Now run the test script at http://localhost/test.php
    • After running test.php successfully, check if you have received the email on receiver email address.
      Was this page helpful?
      Newsletter Subscription
      Subscribing you to the mailing list