WampDeveloper is purely a web-server, and while PHP has a mail() function, it’s useless if not connected to a real mail server, and is not even capable of doing authentication (user/password login) to that mail server.
Running and setting up a mail server can be a complicated affair, here are some simpler options for you:
If you have access to a gmail, hotmail, or yahoo account; or even a SMTP server (mail server) that’s set up to handle your domain-name, you can get WampDeveloper to use any of these to send out emails…
msmtp is a local SMTP application that pretends to be a real SMTP server for PHP, but which really just uses your gmail, hotmail, or yahoo account instead; or any SMTP server (mail server) you’ve configured it to use, that it can login to, and transmit everything to -
Make sure to get version 1.4.31 or above, and not v1.4.30 due to a bug.
WampDeveloper v4.2 already comes with msmtp v1.4.31 (there is no need to download anything).
1. Download and unzip the above as C:\WampDeveloper\Tools\msmtp
(*C:\WampDeveloper\Tools\msmtp\msmtp.exe should be a valid path afterwards)
2. Create file C:\WampDeveloper\Tools\msmtp\msmtprc.ini and place this configuration inside -
# Default values to use for all accounts
# Local Mail Server Account
# This is the simplest example - a mail server on the local network, standard port 25, with no encryption layer
# the user name might be an account username, or your full email address
# ISP Mail Server Account
# Some ISPs provide you with access to a mail server
# the user/password might or might not be required (some ISPs know your IP and give it access automatically)
# the user name might or might not be your ISP provided email address
# Gmail Account
# Hotmail Account
# Yahoo Account
# Default account to use
account default : LocalMailServer
You’ll need to -
a) Edit the above to update the drive letter WampDeveloper is installed on for the “logfile” line.
b) Update your account info for whichever gmail/hotmail/yahoo or SMTP/mail server/service you are using.
The above has been set up with a bunch of defaults for you, and in most cases you’ll just update a) your username/email and password, and b) the default account to use.
3. Edit file -
Uncomment (remove the “;”), and update the path (drive letter), on lines -
sendmail_path = "C:/WampDeveloper/Tools/msmtp/msmtp.exe -d -C C:/WampDeveloper/Tools/msmtp/msmtprc.ini -t --read-envelope-from"
mail.log = "C:/WampDeveloper/Logs/Php/maillog.txt"
Comment out “SMTP =” and “smtp_port =”. This way PHP’s mail() function is using the sendmail application, and not trying to establish it’s own mail server connection.
4. Save edited files. Restart Apache.
Make sure your webapps and/or scripts are configured to use PHP’s mail() function, and not some specific sendmail path or SMTP server. This is what msmtp is for – getting those mail() calls, matching the “From:” address to one of the above accounts, establishing a conection using the account’s settings, and sending your mail via that account’s mail server.
This might require some testing before it starts to work pefectly, as 1) proper mail server settings are needed and 2) the PHP scripts/code you are using must be also using PHP’s mail() function with the proper Headers (From: xxx) included.
Once an email is sent, you’ll be able to see it in the email service’s “Sent” folder.
Be careful not to specify a fake From: address (which does not match your email address for the service) or your emails are going to be tagged as spam.
You’ll also have two log files that you can check -
5. Send test email…
$to = 'firstname.lastname@example.org';
$subject = 'Test Subject';
$message = 'Hello. Testing email.';
$headers = 'From: email@example.com' . "\r\n" .
'Reply-To: firstname.lastname@example.org' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
Running own SMTP server (not recommended)
Some options for SMTP/mail server applications are: hmailserver, mailenable, smartermail, or the native Windows Server SMTP service (*with this one, be careful not to also install and run IIS – which can prevent Apache from binding to port 80 and 443).
You’ll need to first update with your Registrar (domain register – GoDaddy, Namcheap, etc) the DNS records of your mail-server’s domain-names (smtp.your.domain.name) and their IP addresses. Your IPs must be static (can’t change from time to time). Otherwise, set up a local SMTP relay.
Configure the SMTP server to do no-authentication localhost access (PHP’s mail() function does not support authentication – it can only access a SMTP server, but it can not login using a username/password).
Keep the default php.ini settings:
SMTP = 127.0.0.1
smtp_port = 25
Comment out “sendmail_path =”. This way PHP’s mail() function establishes it’s own mail server connection, and dosn’t attempt to use the sendmail application.
You might also need to specify a proper “sendmail_from” setting.
Use an external SMTP service
Set it up to provide service for mail of your domain name. Make sure your domain’s DNS records reflect this service’s mail server names and IP addresses.
Then do the same thing as is option A. Or if your SMTP service allows no-authentication login via a white-listing of your IP, then just fill in the php.ini settings as in option B except with the IP and Port this service provides.
PHPMailer is able to send mail via an SMTP host such as your local or external mail server (gmail), sendmail (and qmail), and PHP’s mail() function.
If using the mail() option, you can integrate it with MSMTP (*and also if using the sendmail option with some more work).
*This assumes your code/scripts are able to utilize something other than the PHP mail() function.
Examples can be found here:
Download and unzip PHPMailer as -
Then start using it:
$mail = new PHPMailer;
sendmail.exe is a simple windows console application that emulates sendmail's "-t" option to deliver emails piped via stdin.
It is intended to ease running unix code that has /usr/lib/sendmail hardcoded as an email delivery means.
It doesn't support deferred delivery, and requires an smtp server to perform the actual delivery of the messages.