Enable PHP Email

This set up works for XAMPP on Windows version 5.6.11 using SMTP server on Bluehost.  I am running on Windows 8.

 

First get Email Client Configuration from Bluehost.

After logging into your domain, go to hosting->email->email configuration.  Select the email account you want to use.  Bluehost will give you information similar to the following:

Email Settings

Mail Server Username: test@example.com

Standard (without SSL)

Incoming Mail Server: mail.example.com
Supported Ports: 143 (IMAP), 110 (POP3)
Outgoing Mail Server: mail.example.com
Supported Port: 26 (server requires authentication)
Private (with SSL)

Incoming Mail Server: box###.bluehost.com (SSL)
Supported Ports: 993 (IMAP), 995 (POP3)
Outgoing Mail Server: box###.bluehost.com (SSL)
Supported Port: 465 (server requires authentication)
Supported Incoming Mail Protocols: POP3, IMAP
Supported Outgoing Mail Protocols: SMTP

 

 

Using sendmailer.exe

First, edit the php.ini file in the php\ subdirectory of your XAMPP installation directory (usually, C:\xampp). Within this file, find the [mail function] section.

Add the following information from Bluehost:

SMTP=box###.bluehost.com (Outgoing Mail Server)
smtp_port=465 (Supported Port under Outgoing Mail Server)

sendmail_from = test@example.com

sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”

make sure you comment out

sendmail_path=”C:\xampp\mailtodisk\mailtodisk.exe”

Double check to make sure duplicate directives are commented out.

 

Second, edit the sendmail.ini file in the sendmail\ subdirectory of your XAMPP installation directory. Within this file, find the [sendmail] section and add the following directives:

smtp_server=box###.bluehost.com (use whatever is listed under Outgoing Mail Server)

smtp_port=465 (use whatever is listed under Supported Port for outgoing mail)

smtp_ssl=auto 

error_logfile=error.log (this will help you debug by showing you errors)

auth_username=test@example.com
auth_password=**********

force_sender=test@example.com

Double check to make sure duplicate directives are commented out.

 

Change sendmail.exe to run in Admin Mode

Go to (xampp directory)/sendmail.  Right click on sendmail.exe.  Choose properties.

 

 

Select Run this program as an administrator and Run this program in compatibility mode for Windows XP service pack 2.  Click on Change settings for all Users if you are not the only user to expect to send email.

sendmail

 

Restart Apache with administrator right.  This is very important.  Otherwise, sendmail will not work.

Use the following code to test the setup.
<?php
$to = 'recipients@email-address.com';
$subject = 'Hello from XAMPP!';
$message = 'This is a test';
$headers = "From: your@email-address.com\r\n";
if (mail($to, $subject, $message, $headers)) {
   echo "SUCCESS";
} else {
   echo "ERROR";
}

A note on using PHPMailer.  I download and included PHPMailer in my code.  However, it didn’t work until I did all the configuration as required to get sendmail working.