You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP. So if you are using XAMPP then you can easily send mail from localhost.
for example you can configure C:\xampp\php\php.ini
and c:\xampp\sendmail\sendmail.ini
for gmail to send mail.
in C:\xampp\php\php.ini
find extension=php_openssl.dll
and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.
in php.ini file find [mail function]
and change
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Now Open C:\xampp\sendmail\sendmail.ini
. Replace all the existing code in sendmail.ini with following code
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]
Now you have done!! create php file with mail function and send mail from localhost.
PS: don't forgot to replace my-gmail-id and my-gmail-password in above code.
Also, don't forget to remove duplicate keys if you copied settings from above. For example comment following line if there is another sendmail_path : sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
in the php.ini file
Also remember to restart the server using the XAMMP control panel so the changes take effect.
For gmail please check https://support.google.com/accounts/answer/6010255 to allow access from less secure apps.
To send email on Linux (with sendmail package) through Gmail from localhost please check PHP+Ubuntu Send email using gmail form localhost.
In XAMPP v3.2.1 for testing purposes you can see the emails that the XAMPP sends in XAMPP/mailoutput. In my case on Windows 8 this did not require any additional configuration and was a simple solution to testing email
you should use Papercut this simple application to test send mail. and you don't need to configure anything.
Just run it and try test send mail:
test_sendmail.php
<?php
$to = "[email protected]";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: [email protected]" . "\r\n" .
"CC: [email protected]";
mail($to,$subject,$txt,$headers);
?>
and you will see this:
I hope you will have a good day. you can find me on Youtube for more tutorial Piseth Sok
Cheer!
Its very simple to send emails on localhost or local server
Note: I am using the test mail server software on Windows 7 64bit with Xampp installed
Just download test mail server tool and install according to the instruction given on its website Test Mail Server Tool
Now you need to change only two lines under php.ini
file
[mail function]
and remove semi colon which is before ;smtp = localhost
sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"
You don't need to change anything else, but if you still not getting emails than check for the SMTP port
, the port number must be same.
The above method is for default settings provided by the Xampp software.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With