Why is Sendmail on WAMP Server Failing to Send Emails with a Gmail Account?

DDD
Release: 2024-10-28 08:27:29
Original
891 people have browsed it

Why is Sendmail on WAMP Server Failing to Send Emails with a Gmail Account?

Troubleshooting Sendmail with WAMP Server and PHP for Gmail Account

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:

  1. Right-click on sendmail.exe and select "Properties."
  2. Navigate to the "Compatibility" tab.
  3. Select "Change settings for all users."
  4. Under "Compatibility mode," select "Run this program in compatibility mode for:" and choose "Windows XP SP 3."
  5. Check the box "Run this program as an administrator."
  6. Click "Apply" and "OK" to save changes.

Additional Details:

  • Sendmail Configuration:

    • smtp_server=smtp.gmail.com
    • smtp_port=465
    • smtp_ssl=ssl
  • PHP Configuration:

    • smtp_port = 465
    • sendmail_path="C:wampsendmailsendmail.exe -t"
  • Additional Notes:

    • SSL module is enabled in Apache.
    • PHP uses php_open_ssl and php_socket extensions.

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>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template