Asked  7 Months ago    Answers:  5   Viewed   42 times

I want to use the mail() function from my localhost. I have WAMP installed and a Gmail account. I know that the SMTP for Gmail is and the port is 465 (more info from gmail). What I need to configure in WAMP so I can use the mail() function?




Gmail servers use SMTP Authentication under SSL or TLS. I think that there is no way to use the mail() function under that circumstances, so you might want to check these alternatives:

  • PEAR::Mail
  • phpMailer
  • NetteMail

They all support SMTP auth under SSL.

You'll need to enable the php_openssl extension in your php.ini.

Additional Resources:

  • How to Send Email from a PHP Script Using SMTP Authentication (using PEAR::Mail)
  • Send email using PHP with Gmail (using phpMailer)
  • Mailing using NetteMail
Wednesday, March 31, 2021
answered 7 Months ago

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:

It worked right off the bat for me, hope this helps you.

Monday, June 7, 2021
answered 5 Months ago

You can also look at this answer specially if you are now using WAMPServer 3 or greater, for a simple clikc and go way to create Virtual hosts.

Actually this change was intended by the WAMPServer developers and for a good reason.

There is a problem using the localhost/project1 url and the default WAMPServer DocumentRoot in that it causes problems for some frameworks and WordPress type environments, as well as your own code if you are using code which depends on knowing anything about the server environment.

The correct solution is to create Virtual Hosts for all your projects even those that you store in the wampwwwproject1 style folders.

When doing that the DocumentRoot is wampwww and that is what causes these problems.

These tools expect the DocumentRoot to be the root of the site i.e. wampwwwproject1 so that when they use PHP variables like


they get the correct answer i.e. the answer they would get on a real live server hosting just that site.

So using the localhostproject1 style url would mean these variables would return

$_SERVER['HTTP_HOST'] = localhost
$_SERVER['SERVER_NAME'] = localhost
$_SERVER['DOCUMENT_ROOT'] = C:/wamp/www

When they should return

$_SERVER['HTTP_HOST'] = project1
$_SERVER['SERVER_NAME'] = project1
$_SERVER['DOCUMENT_ROOT'] = C:/wamp/www/project1

So what you should do to make the My Projects menu work and reduce your pain in copying sites to live servers is:

Create an entry in the HOSTS file for each project like so and remember to create one for access via IPV4( and one for access via IPV6 (::1):- localhost project1

::1 localhost
::1 project1

Remember to refresh the Windows DNS Cache after any change to this file like so :-

Start a command window using Run as Administrator and run :-

net stop Dnscache
net start Dnscache

Now you must create a Virtual Host definition, so edit the wampbinapacheapache2.4.9confextrahttpd-vhost.conf file ( apache versions may differ )

Delete the default stuff in there the first time you do this. And then create your Virtual Host definitions like so :-

# Use name-based virtual hosting.
# This next line is not required if you are using Apache 2.4.x and should be deleted
NameVirtualHost *:80

## should be first so the wamp menu page loads and is the default site
## should also never be changed from only allowing access from the local machine
## for a bit of extra security from casual ip address probing
<VirtualHost *:80>
    DocumentRoot "C:/wamp/www"
    ServerName  localhost
    ServerAlias localhost
    <Directory  "C:/wamp/www">
        AllowOverride All

        <IfDefine APACHE24>
            Require local

        <IfDefine !APACHE24>
            Order Deny,Allow
            Deny from all
            Allow from localhost ::1

<VirtualHost *:80>
    DocumentRoot "C:/wamp/www/project1"
    ServerName  project1
    ServerAlias project1
    <Directory  "C:/wamp/www/project1">
        AllowOverride All

        <IfDefine APACHE24>
            Require local

        <IfDefine !APACHE24>
            Order Deny,Allow
            Deny from all
            Allow from localhost ::1


Now you need one more change, you must uncomment the line in httpd.conf that includes the above file we have just changed. So edit the httpd.conf file, use the wampmanager menus to do this as it ensures you edit the correct file.

Find this line #Include conf/extra/httpd-vhosts.conf and remove the comment # symbol from the beginning of the line like so :-

Include conf/extra/httpd-vhosts.conf

Now of course you will need to restart Apache so that it picks up your configuration changes.

If Apache does not restart, you probably made a mistake in the config, to find out what is wrong try this.

Open a command window and CD into the wampbinapacheapache2.4.9bin folder.

Then run this :-

httpd -t

If the error is in httpd.conf or the httpd-vhost.conf files it will tell you the error and also give you the line number to make finding the error very easy.

Monday, June 28, 2021
answered 4 Months ago

I found the solution to my question:

var RequestArguments = {
  headers: {Authorization: 'Bearer ' + token},
  method: "post",
  contentType: "application/json",
  payload: JSON.stringify(jsonMessage)

jsonMessage is the whole message, not only the raw part!

Saturday, July 31, 2021
answered 3 Months ago

Ok, I contacted Google directly to get the answer and here is their reply:

Thank you for your message.

I understand you have a query regarding the Google Apps for Business sending limits. As mentioned in our Help Center article at, the daily limitation is 2000 messages in a 24-hour period not day. In general, our servers can tolerate one message per second until sending limits are hit. We really don't have an hourly or minute limitation for sending. If you send messages too quickly you may get rate-limited but the account should not lock out.

By rate-limt, since in general one message per second, if you try to send too many messages per second you may get a message telling you that the message cannot be send or you must wait before sending a message.

So after their response we did a test of 1,000 emails. We would send an email out, wait for sent confirmation, wait 2 seconds, and then send the next one. This resulted in successfully sending out all 1,000 emails in about 55 minutes with a gap of 3-4 seconds between each email. Below is the code we used.


$mail = new PHPMailer();

$mail->Host = "";
$mail->SMTPAuth = true;
$mail->Username = 'USERNAME';
$mail->Password = 'PASSWORD';

$mail->From     = "";
$mail->FromName = "Gmail Test";


for($i=0; $i<=1000; $i++){
    $date = date("H:i:s m/d/Y");
    $mail->Subject  = "$date";

    $mail->Body = "Test $i of PHPMailer.";

       echo "Error sending: " . $mail->ErrorInfo;
       echo "$i. E-mail sent => $date<BR>";

Sunday, August 1, 2021
Sam Adamsh
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :