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
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.
Configure WAMP server to send email
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:
http://www.toolheap.com/test-mail-server-tool/
It worked right off the bat for me, hope this helps you.
(WAMP/XAMP) send Mail using SMTP localhost
You can use this library to send email ,if having issue with local xampp,wamp...
class.phpmailer.php,class.smtp.php
Write this code in file where your email function calls
include('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "your email ID";
$mail->Password = "your email password";
$fromname = "From Name in Email";
$To = trim($email,"\r\n");
$tContent = '';
$tContent .="<table width='550px' colspan='2' cellpadding='4'>
<tr><td align='center'><img src='imgpath' width='100' height='100'></td></tr>
<tr><td height='20'> </td></tr>
<tr>
<td>
<table cellspacing='1' cellpadding='1' width='100%' height='100%'>
<tr><td align='center'><h2>YOUR TEXT<h2></td></tr/>
<tr><td> </td></tr>
<tr><td align='center'>Name: ".trim(NAME,"\r\n")."</td></tr>
<tr><td align='center'>ABCD TEXT: ".$abcd."</td></tr>
<tr><td> </td></tr>
</table>
</td>
</tr>
</table>";
$mail->From = "From email";
$mail->FromName = $fromname;
$mail->Subject = "Your Details.";
$mail->Body = $tContent;
$mail->AddAddress($To);
$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low
$mail->Send();
WAMP & SendMail not working with GMAIL
This is from : http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/
I followed the steps and was able to send emails from wamp server. Your problem seems to be the name of the folder "Program Files" it has a space in it.
If the path to the sendmail.exe contains “space” (for example, “C:\Program Files\PHP\sendmail\”) then Apache would not be able to locate it. So, either store the sendmail.exe at a “non-spaced” location/path OR write the path in DOS style “C:\Progra~1\PHP\sendmail\” in the php.ini (sendmail_path = "C:\Progra~1\PHP\sendmail\sendmail.exe -t -i").
Related Topics
Special Characters in PHP/Mysql
Utf-8 Safe Equivalent of Ord or Charcodeat() in PHP
Create New Variables from Array Keys in PHP
Single Quotes or Double Quotes for Variable Concatenation
Include Constant in String Without Concatenating
Service Applications and Google Analytics API V3: Server-To-Server Oauth2 Authentication
How to Get Current Time in Milliseconds in PHP
Require(Vendor/Autoload.Php): Failed to Open Stream
Increase Max Execution Time for PHP
How to Schedule the Execution of a PHP Script on the Server Side
How to Use Multiple Databases Dynamically for One Model in Cakephp
Checking If All the Array Items Are Empty PHP
Woocommerce: Add Product to Cart with Price Override
How to Generate Random 64-Bit Value as Decimal String in PHP