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.
PHP : send mail in localhost
It is configured to use localhost:25
for the mail server.
The error message says that it can't connect to localhost:25
.
Therefore you have two options:
- Install / Properly configure an SMTP server on localhost port 25
- Change the configuration to point to some other SMTP server that you can connect to
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:
- Open hMailServer Administrator.
- Click the "Add domain ..." button to create a new domain.
- Under the domain text field, enter your computer's localhost IP.
- Example: 127.0.0.1 is your localhost IP.
- Click the "Save" button.
- Now go to Settings > Protocols > SMTP and select the "Delivery of Email" tab.
- Find the localhost field enter "localhost".
- Click the Save button.
Configure your Gmail account, perform following modification:
- Go to Settings > Protocols > SMTP and select "Delivery of Email" tab.
- Enter "smtp.gmail.com" in the Remote Host name field.
- Enter "465" as the port number.
- Check "Server requires authentication".
- Enter your Google Mail address in the Username field.
- Enter your Google Mail password in the password field.
- Check mark "Use SSL"
- 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:
- Go to Settings > Advanced > IP Ranges and double click on "My Computer" which
should have IP address of 127.0.0.1 - Check the Allow Deliveries from External to External accounts Checkbox.
- Save settings using Save button.
Sending email from localhost server xampp/sendmail
Try this
sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
auth_username=[email]@gmail.com
auth_password=[email password]
pop3_server=
pop3_username=
pop3_password=
force_sender=[email]@gmail.com
force_recipient=
hostname=smtp.gmail.com
php.ini
[mail function]
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off
Related Topics
Php: Locale Aware Number Format
PHP Include Causes White Space at the Top of the Page
Error: File Is Encrypted or Is Not a Database
Use Curly Brackets to Structure Code in PHP
Setting Document Root for Laravel Project on Apache Virtual Host
Sort Multidimensional Array by Date Column, Then Use Other Column Values If Dates Are the Same
Undefined Index with PHP Sessions
What Is the Type This String? A:1:{S:2:"En";}
How to Properly Handle Session and Access Token with Facebook PHP Sdk 3.0
Laravel 5.2 Cors, Get Not Working with Preflight Options
Laravel 5.1: Keep Uploaded File as Old Input
Invoke External Shell Script from PHP and Get Its Process Id
How to Paginate Lines in a Foreach Loop with PHP
Mod_Rewrite, PHP and the .Htaccess File