Test sending emails with PapercutSMTP in PHP using XAMPP

Sending email with PHP is very easy. We can create a local SMTP server to test it. There are many apps available for that. But In this article we are going to use PapercutSMTP.

PapercutSMTP logo


Papercut creates a local SMTP server for testing purpose. This is probably the best app for this on Windows platform. Let’s see how to download and configure PapercutSMTP.

Download PapercutSMTP

You download latest PapercutSMTP app from GitHub releases page. Look for Papercut.Setup.exe , download and install it from the following link. https://github.com/ChangemakerStudios/Papercut-SMTP/releases

Sending email

We can send email with mail() in PHP. Now create a PHP file like the following


$to = 'recipients@email-address.com';
$subject = 'Hello from XAMPP!';
$message = 'This is a PapercutSMTP test';
$headers = "From: your@email-address.com\r\n";

if (mail($to, $subject, $message, $headers)) {
echo "SUCCESS";
} else {
echo "ERROR";

If you open the page in the browser you should see a success message.

A notifcation will also appear in the notification area.

You can open the PapercutSMTP app to see all the local emails sent.

You can also access the web based UI from

If you see the email in the box, you are done ! You can skip rest of this post.


If you face any problems in the step above you can the configuration. If something is changed update it according to this post otherwise ignore it.

Update PHP configuration

Open php.ini and search for mail function. Set SMTP=localhost and smtp_port=25 in php.ini file.

[mail function]
; For Win32 only.
; http://php.net/smtp
; http://php.net/smtp-port

Update sendmail configuration

Open sendmail.ini from C:\xampp\sendmail\ directory and put smtp_server=localhost and smtp_port=25.


Related posts

Md. Monirul Alom

Md. Monirul Alom

I am a Full Stack Web developer. I love to code, travel, do some volunteer work. Whenever I get time I write for this blog