Send Email from Localhost with Gmail(Windows)

Sending email from localhost

If you want to send emails from localhost directly, you need to install a Mail Transport Agent (MTA), or if you like, a SMTP service.

IIS provides one. You can otherwise find some others on Google.

You can also change your php.ini mail settings. This won't use localhost per say to send emails, but a relay host that will allow you to send emails from a PHP script.

How to configure WAMP (localhost) to send email using Gmail?

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
  • Nette\Mail

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 Nette\Mail

Send email from localhost running XAMMP in PHP using GMAIL mail server

Here's the link that gives me the answer:

[Install] the "fake sendmail for windows". If you are not using XAMPP you can download it here: http://glob.com.au/sendmail/sendmail.zip

[Modify] the php.ini file to use it (commented out the other lines):

[mail function]
; For Win32 only.
; SMTP = smtp.gmail.com
; smtp_port = 25

; For Win32 only.
; sendmail_from = <e-mail username>@gmail.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

(ignore the "Unix only" bit, since we actually are using sendmail)

You then have to configure the "sendmail.ini" file in the directory where sendmail was installed:

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=<username>
auth_password=<password>
force_sender=<e-mail username>@gmail.com

To access a Gmail account protected by 2-factor verification, you will need to create an application-specific password. (source)

How to send email from localhost WAMP Server to send email Gmail Hotmail or so forth?

Configuring a working email client from localhost is quite a chore, I have spent hours of frustration attempting it. At last I have found this way to send mails (using WAMP, XAMPP, etc.):

Install hMailServer

Configure this hMailServer setting:

  1. Open hMailServer Administrator.
  2. Click the "Add domain ..." button to create a new domain.
  3. Under the domain text field, enter your computer's localhost IP.

    • Example: 127.0.0.1 is your localhost IP.
  4. Click the "Save" button.
  5. Now go to Settings > Protocols > SMTP and select the "Delivery of Email" tab.
  6. Find the localhost field enter "localhost".
  7. Click the Save button.

Configure your Gmail account, perform following modification:

  1. Go to Settings > Protocols > SMTP and select "Delivery of Email" tab.
  2. Enter "smtp.gmail.com" in the Remote Host name field.
  3. Enter "465" as the port number.
  4. Check "Server requires authentication".
  5. Enter your Google Mail address in the Username field.
  6. Enter your Google Mail password in the password field.
  7. Check mark "Use SSL"
  8. Save all changes.


Optional

If you want to send email from another computer you need to allow deliveries from External to External accounts by following steps:

  1. Go to Settings > Advanced > IP Ranges and double click on "My Computer" which
    should have IP address of 127.0.0.1
  2. Check the Allow Deliveries from External to External accounts Checkbox.
  3. Save settings using Save button.



Related Topics



Leave a reply



Submit