Is there a way that I can configure the WAMP server for PHP to enable the mail()
function?
7 Answers
Configuring a working email client from localhost is quite a chore, I have spent hours of frustration attempting it. I'm sure someone more experienced may be able to help, or they may perhaps agree with me.
If you just want to test, here is a great tool for testing mail locally, that requires almost no configuration:
-
16Works with wamp with no config watsoever. Just open the .eml with windows live mail (no config needed). Jan 28, 2013 at 10:36
-
5If (like me) you came to this great solution after tweaking php.ini, remember the default config: [mail function] SMTP = localhost smtp_port = 25– BenLDec 12, 2014 at 11:01
-
2
-
5to whoever doesn't find the download link go to here: toolheap.com/test-mail-server-tool/users-manual.html Feb 10, 2019 at 19:28
-
3For those who want to download this without disabling adblock, here is the download link: toolheap.com/test-mail-server-tool/TestMailServerToolSetup.exe Aug 28, 2019 at 15:52
Install Fake Sendmail (download sendmail.zip). Then configure C:\wamp\sendmail\sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password
The above will work against a Gmail account. And then configure php.ini:
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Now, restart Apache, and that is basically all you need to do.
-
3+1 for turnkey solution. As an added resource for those who need a little more detail on the steps: blog.techwheels.net/…– PrusprusFeb 17, 2014 at 0:27
-
@gianjey Will this work with other accounts such as Hotmail or do you need a Gmail account registered to use this? Apr 6, 2014 at 13:18
-
1dang this method doesn't appear to be working anymore ... assuming i've gotten everything set up correctly– BanningNov 5, 2014 at 4:32
-
Hi @Banning, I was able to set this up without difficulty just now so it still works. Make sure you don't have two-step authentication configured on the GMail account. Anyway, this was a good guide - blog.techwheels.net/…– faludiNov 25, 2014 at 16:00
-
1Cant believe this worked first try!!! so incredible. Only part that messed me up is, if you are using gmail you need to put in your gmail user name and password so it can sign into the email client to SEND the email. NOTE: if you are going to do this, make a new gmail account since this increases the risk of security risk. Sep 29, 2016 at 14:18
Using an open source program call Send Mail, you can send via wamp rather easily actually. I'm still setting it up, but here's a great tutorial by jo jordan. Takes less than 2 mins to setup.
Just tried it and it worked like a charm! Once I uncommented the error log and found out that it was stalling on the pop3 authentication, I just removed that and it sent nicely. Best of luck!
-
If you're using a Gmail account, you need to allow access for less secure apps. To do this, when you've done what is says in the tutorial linked in this answer and opened a PHP page with
mail
, you will receive an email from Google saying that a sign-in attempt was blocked. In that email, click on "Check activity", and in the page that opens, click on "Yes, it was me", then click on "Learn more", then click on "If 'Less secure app access' is off for your account", then click on "turn it back on", and then turn the switch on. Aug 28, 2019 at 16:21 -
Also, you must specify a
from
header when callingmail
in PHP. For example, you can domail("to@example.com", "Subject", "Content", "From: youremailaddress@gmail.com")
(it's the last parameter that's important). Aug 28, 2019 at 16:28
You need a SMTP server to send your mail. If you have one available which does not require SMTP authentification (maybe your ISP's?) just edit the 'SMTP' ([mail function]) setting in your php.ini file.
If this is no option because your SMTP server requires authentification you won't be able to use the internal mail() function and have to use some 3rd party class which supports smtp auth. e.g. http://pear.php.net/package/Mail/
I tried Test Mail Server Tool and while it worked great, you still need to open the email on some client.
I found Papercut:
https://github.com/ChangemakerStudios/Papercut-SMTP (updated URL for 2021)
For configuration it's easy as Test Mail Server Tool (pratically zero-conf), and it also serves as an email client, with views for the Message (great for HTML emails), Headers, Body (to inspect the HTML) and Raw (full unparsed email).
It also has a Sections view, to split up the different media types found in the email.
It has a super clean and friendly UI, a good log viewer and gives you notifications when you receive an email.
I find it perfect, so I just wanted to give my 2c and maybe help someone.
-
1Your link is now outdated. Here's the project in 2021 on Github: github.com/ChangemakerStudios/Papercut-SMTP Aug 14, 2021 at 13:27
Sendmail wasn't working for me so I used msmtp 1.6.2 w32 and most just followed the instructions at DeveloperSide. Here is a quick rundown of the setup for posterity:
Enabled IMAP access under your Gmail account (the one msmtp is sending emails from)
Enable access for less secure apps. Log into your google account and go here
Edit php.ini
, find and change each setting below to reflect the following:
; These are commented out by prefixing a semicolon
;SMTP = localhost
;smtp_port = 25
; Set these paths to where you put your msmtp files.
; I used backslashes in php.ini and it works fine.
; The example in the devside guide uses forwardslashes.
sendmail_path = "C:\wamp64\msmtp\msmtp.exe -d -C C:\wamp64\msmtp\msmtprc.ini -t --read-envelope-from"
mail.log = "C:\wamp64\msmtp\maillog.txt"
Create and edit the file msmtprc.ini
in the same directory as your msmtp.exe
file as follows, replacing it with your own email and password:
# Default values for all accounts
defaults
tls_certcheck off
# I used forward slashes here and it works.
logfile C:/wamp64/msmtp/msmtplog.txt
account Gmail
host smtp.gmail.com
port 587
auth on
tls on
from ReplaceWithYourEmail@gmail.com
user ReplaceWithYourEmail@gmail.com
password ReplaceWithYourPassword
account default : gmail
-
I couldn't install msmtp on windows. I can only find tar files. May 28, 2019 at 15:17
-
1Try the link in my answer and download
msmtp-1.6.2-w32.zip
sourceforge.net/projects/msmtp/files/msmtp/1.6.2– iyrinJun 15, 2019 at 5:22
I used Mercury/32 and Pegasus Mail to get the mail() functional. It works great too as a mail server if you want an email address ending with your domain name.