Issue:
Unable to send emails using sendmail with a Gmail account from WAMP Server on Windows 8.1.
Problem:
Socket errors or "Connection Closed Gracefully" when using port 465 or 587.
Solution:
The issue is resolved by running sendmail.exe as an administrator. Here are the steps:
Additional Details:
Sendmail Configuration:
PHP Configuration:
Additional Notes:
PHP Code for Testing:
<code class="php">$email = "youremail@gmail.com"; $to = "receiveremail@gmail.com"; $subject = "Hi!"; $body = "Hi,How are you?"; $headers = 'From: ' .$email . "\r\n".'Reply-To: ' . $email. "\r\n".'X-Mailer: PHP/' . phpversion(); if (mail($to, $subject, $body, $headers)) echo("<p>Email successfully sent</p>"); else echo("<p>Email delivery failed</p>");</code>
By following these steps, sendmail will now run with elevated privileges and should successfully send emails through the Gmail account.
The above is the detailed content of Why is Sendmail on WAMP Server Failing to Send Emails with a Gmail Account?. For more information, please follow other related articles on the PHP Chinese website!