Reset a password using SMTP
-
Sending normal messages using SMTP works perfectly. However, when attempting to reset a password on the WordPress login page, I encounter the error message: ‘Error: The email could not be sent. Your site may not be correctly configured to send emails.’ It seems that WordPress does not utilize SMTP for password resets. Instead, it uses the following mail settings:
Current mail settings:
- Mailer: mail
- SendMail path: /usr/sbin/sendmail
- Host: localhost
- Port: 25
These settings suggest that WordPress is configured to use the server’s default mail handling (sendmail) rather than SMTP, which may be why password reset emails are not being sent.
add_action('phpmailer_init', 'my_phpmailer_smtp');
function my_phpmailer_smtp($phpmailer) {
? ? error_log('my_phpmailer_smtp function is called');
? ? $phpmailer->isSMTP();
? ? $phpmailer->Host = SMTP_SERVER;
? ? $phpmailer->SMTPAuth = SMTP_AUTH;
? ? $phpmailer->Port = SMTP_PORT;
? ? $phpmailer->Username = SMTP_USERNAME;
? ? $phpmailer->Password = SMTP_PASSWORD;
? ? $phpmailer->SMTPSecure = SMTP_SECURE;
? ? $phpmailer->From = SMTP_FROM;
? ? $phpmailer->FromName = SMTP_NAME;
? ? $phpmailer->SMTPDebug = SMTP_DEBUG; // Set to 1 or 2 for debugging (only for testing)
? ? $phpmailer->CharSet = 'UTF-8';
}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.