😅Cách để gửi mail bằng WP SMTP trên localhost windows full pass moi (ok)

https://wordpress.org/plugins/wp-smtp/

Mat khau moi: phamngoctuong1805@gmail.com appmail wrojrhklvdzkfnbh 6/6/2024

Bước 1: C:\Users\Administrator\OneDrive\Desktop\test.php

mail( 'phamngoctuong1805@gmail.com', 'Works!', 'An email has been generated from your localhost, congratulations!')

Hiện tại check 20-20-2023 bị lỗi plugin WP SMTP không hoạt động được xem cách khắc phục bên dưới (1)

😒Chú ý: Quan trọng nhất vẫn là dòng này (đã gặp lỗi mãi không gửi mail)

trong php.ini chỉ cần cài cái này là đủ. Không cần đến SMTP=localhost smtp_port = 25

sendmail_path=C:\xampp\sendmail\sendmail.exe

Quan trọng nhất là cái này :)

C:\xampp\htdocs\reset\wp-content\themes\twentytwentyone\functions.php

add_filter('wp_mail_from','from_mail');
function from_mail($content_type) {
    return 'phamngoctuong1805@gmail.com';
}

C:\xampp\sendmail\sendmail.ini

; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory.  (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=587

; SMTPS (SSL) support
;   auto = use SSL for port 465, otherwise try to use TLS
;   ssl  = alway use SSL
;   tls  = always use TLS
;   none = never try to use SSL

smtp_ssl=auto

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=mydomain.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=phamngoctuong1805@gmail.com
auth_password=nmobazrhdoxxlznl

; if your smtp server uses pop3 before smtp authentication, modify the 
; following three lines.  do not enable unless it is required.

pop3_server=
pop3_username=
pop3_password=

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify 
; the "From: " header of the message content

force_sender=phamngoctuong1805@gmail.com

; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify 
; the "To: " header of the message content

force_recipient=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting.  you can manually set the ehlo/helo name if required

hostname=localhost

C:\xampp\php\php.ini

Có cả đoạn script để test

C:\xampp\htdocs\html\contact.php

Or

(1) Hiện tại check 20-20-2023 bị lỗi plugin WP SMTP không hoạt động được xem cách khắc phục bên dưới (1) sử dụng plugin này Gmail SMTP Bởi naa986

Link: https://console.cloud.google.com/apis/credentials?project=test-gmail-new-20-10-2023

Cần add thêm tên miền vào đây

Chú ý phải vào đây public ứng dụng

Link: https://console.cloud.google.com/apis/credentials/consent/edit?project=test-gmail-new-20-10-2023

Gmail SMTP Plugin for WordPress

by WPHowTo

Gmail SMTP is an advanced SMTP mailing plugin for WordPress for sending an email via Gmail SMTP server. Unlike most SMTP plugins It uses the OAuth 2.0 protocol to authorize access to the Gmail API instead of password authentication.

Table of Contents

gmail smtp wordpress plugin

Gmail SMTP Info

Plugin Name: Gmail SMTPVersion: 1.2.3.5File Format: application/zipRequires: WordPress 6.1Rating: 4.1 based on 95 votesSee All Ratings/Submit Your Rating HerePrice: 0 USD

Gmail SMTP Benefits

1. Gmail SMTP plugin does not store your password. It uses the OAuth 2.0 mechanism for SMTP authentication. It means a more secure login system for users.

2. Gmail SMTP plugin uses PHPMailer – a very popular PHP library used in the core WordPress for sending an email. This is to make sure that users can still get full benefits of the default email functionality.

Ezoic

3. Gmail SMTP plugin takes a big headache away from you because you no longer need to Allow Less Secure Apps on your Gmail account. This is an option that users had to enable in order to fix SMTP connection issue. This issue went viral from December 2014, when Google started imposing OAuth 2.0 authentication to access their apps. This option affects SMTP mailing because applications that perform password authentication to IMAP, POP, or SMTP are considered Less Secure Apps.

As far as I know, this issue still affects almost all the SMTP plugins out there.

How OAuth 2.0 Authorization Works

1. You register a web application in the Google Developers Console.

Ezoic

2. When this application is launched it requests that you give it access to data in your Google account.

3. If you consent, the application receives credentials to access the API.

Installation

You can install the Gmail SMTP plugin in one of the following ways:

Option 1 (Quick & Easy install)

  1. Go to Plugins->Add New from your WordPress admin dashboard

  2. Search for Gmail SMTP

  3. Click Install once you have found it

Option 2 (Manual install)

  1. Download the zip version of the plugin

  2. Go to Plugins->Add New

  3. Click Upload Plugin

  4. Select the zip file on your computer

  5. Install it

Gmail SMTP Configuration

In order to get started with the plugin go to Settings->Gmail SMTP from your admin dashboard.

Ezoic

screenshot of gmail smtp plugin menu

Gmail SMTP Project Creation

1. Go to console.cloud.google.com/apis/dashboard.

2. Login to your Google account which will be used to send an email.

3. Create a new project where your application will be registered.

screenshot showing how to create a new project in the Google Developers Console

It doesn’t have to be “Gmail SMTP Project 1”. You can name it whatever you like. I chose a meaningful name because I have multiple projects in it.

Ezoic

Credentials/App Creation

1. Once the project is created go to Credentials > CREATE CREDENTIALS and select OAuth client ID.

2. In order to create an OAuth client ID, you need to configure the OAuth consent screen first. So click CONFIGURE CONSENT SCREEN.

screenshot showing how to configure the consent screen when creating an OAuth Client ID

3. Choose how you want to configure and register your app. Since I’m not using G Suite I had to choose External.

screenshot showing how to choose a user type in the oauth consent screen of the google developers console

4. Enter a name (e.g. Gmail SMTP) for the OAuth consent screen.

Ezoic

screenshot showing the OAuth consent screen 2 in the google developers console

5. You can configure optional fields such as Authorized domains, Application home page, Application privacy policy link and Application terms of service link (I was able to skip all and click SAVE AND CONTINUE). You do however need to enter an email address under the Developer contact information section.

screenshot showing part 2 of the consent screen 2 in the google developers console

6. Skip the Scopes screen.

screenshot showing the Scopes tab in the OAuth consent screen of the Google cloud console

7. Add a test user if you plan to use this app in test mode (This is not required if you want to publish it).

screenshot showing the Test users tab in the OAuth consent screen of the Google cloud console

8. Keep your app in test mode or publish it. If the Publishing status is set to In production, a warning message (This app isn’t verified) may appear on the consent screen that you can easily skip.

Ezoic

screenshot showing the Summary tab in the OAuth consent screen of the Google cloud console

Now that the OAuth consent screen has been configured you can create an OAuth Client ID.

9. Go to the Credentials tab and select OAuth client ID under CREATE CREDENTIALS.

screenshot showing how to select OAuth client Id under CREATE CREDENTIALS in the google developers console

10. Set the application type to Web application and enter a name for it (e.g. Gmail SMTP App). Copy the Authorized Redirect URL from the settings and paste it into the field here.

screenshot showing how to create a client id by creating a new web app in the google developers console

11. Click Create. This will generate a Client ID and Client Secret for you. Copy and paste them into the settings area of the plugin.

Ezoic

Gmail SMTP Settings Configuration

1. Configure the rest of the settings. It includes,

OAuth Email Address: The email address that you will use for SMTP authentication. This should be the same email used in the Google Developers Console.

From Email Address: The email address which will be used as the From Address when sending an email.

From Name: The name which will be used as the From Name when sending an email.

Ezoic

Type of Encryption: The encryption which will be used when sending an email (either TLS/SSL). By default, it should be set to TLS since SSL has been deprecated since 1998.

SMTP Port: The port which will be used when sending an email. If you choose TLS it should be set to 587. For SSL use port 465 instead.

2. Click Save Changes.

Now that you have configured the settings a Grant Permission button will appear.

screenshot showing how to grant permission from the gmail smtp settings

3. Clicking on it will take you to a consent screen where you will be able to grant this app access to the Gmail API.

Ezoic

allow application screen of google developers console

4. When you click Allow you will get redirected back to the plugin settings. You should see a message like Access Granted Successfully. The SMTP Status should also get set from Not Connected to Connected.

screenshot of gmail smtp settings

That’s it. Gmail SMTP plugin will now be able to take control of all outgoing email from your website.

Test Email

In order to test the email functionality, you can send a test email from the Test Email tab.

Debug option is enabled by default for the test email functionality – which means you would be able to see if the plugin was able to send the email without any error.

screenshot showing how to send a test email from the gmail smtp plugin settings

Troubleshooting

By default, your SMTP port should be configured on 587 (with TLS encryption). If you can’t get it to work then you can try changing it to 465 (with SSL encryption).

Ezoic

If you still can’t get either to work try port 25 with TLS first and then SSL. Please note that most servers don’t support encryption on port 25, which is why port 587 and 465 are the preferred options.

Fresh Authorization / Removing Access From the Application

For some reason, if you ever want to stop using this plugin or do a fresh authorization this option might come in handy.

Revoke Access menu allows you to remove access from a previously authorized application.

screenshot showing the revoke access settings of gmail smtp plugin

First, you need to click on the account settings link. This will take you to a page where you can remove access from the Gmail SMTP application.

screenshot showing how to remove access from an application in the google developers console

Once you have removed access from it, go back to the Remove Access tab in the plugin settings and delete the Access key.

Ezoic

Access key is a token that the plugin received when you first granted your app access to the Gmail API. This token is necessary to communicate with the Gmail API and send an email. In order to avoid any confusion, the plugin does not show it on the settings page.

Once you delete this token the plugin can no longer connect to the Gmail SMTP server or send an email. This means you will need to reauthorize (using the web application link in the settings) before you can start using the plugin again. However, you won’t need to set up everything from scratch as long as the project still exists in your Google Developers Console.

Gmail SMTP Add-ons

Gmail SMTP plugin comes with add-ons that you can use to enhance its functionality on your website.

Reply-To

Reply-To add-on lets you set a reply-to address for all outgoing email messages.

Cc

Cc add-on lets you set a cc recipient for all outgoing email messages.

EzoicIf you like our free plugins you can support them here

Gmail SMTP Plugin Cc Configuration

SMTP Mailer Plugin For WordPress

How to Add a Reply-To Address in the Gmail SMTP WordPress Plugin

Categoriesplugin, wordpressWhy WP Engine has the Fastest WordPress PlatformAffiliates Manager vs Affiliate Platform

701 thoughts on “Gmail SMTP Plugin for WordPress”

Comment navigation

← Older Comments

  1. Krista

    Hello,

    I have connected my API. It seems to be correct. But while testing email I receive the following mistake:

    Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /var/www/my_domain_example.com/public_html/wp-content/plugins/gmail-smtp/main.php:677 Stack trace: #0 /var/www/my_domain_example.com/public_html/wp-includes/class-wp-hook.php(307): gmail_smtp_pre_wp_mail() #1 /var/www/my_domain_example.com/public_html/wp-includes/plugin.php(189): WP_Hook->apply_filters() #2 /var/www/my_domain_example.com/public_html/wp-includes/pluggable.php(222): apply_filters() #3 /var/www/my_domain_example.com/public_html/wp-content/plugins/gmail-smtp/main.php(186): wp_mail() #4 /var/www/my_domain_example.com/public_html/wp-content/plugins/gmail-smtp/main.php(123): GMAIL_SMTP->test_email_settings() #5 /var/www/my_domain_example.com/public_html/wp-includes/class-wp-hook.php(307): GMAIL_SMTP->options_page() #6 /var/www/my_domain_example.com/public_html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #7 /var/www/my_domain_example.com/public_html/wp-includes/plugin.php(474): WP_Hook->do_action() #8 /var/www/my_domain_example.com/public_html/wp-admin/admin.php(259): do_action() #9 /var/www/my_domain_example.com/public_html/wp-admin/options-general.php(10): require_once(‘…’) #10 {main} thrown in /var/www/my_domain_example.com/public_html/wp-content/plugins/gmail-smtp/main.php on line 677 There has been a critical error on this website. Please check your site admin email inbox for instructions.

    Any ideas? Thanks

    Reply

  2. Krista

    Follow up. Server info”

    OS: Linux my_domain.com 5.4.0-88-generic #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 PHP version: 8.0.11 WordPress version: 5.9 WordPress multisite: No openssl: Available allow_url_fopen: Enabled stream_socket_client: Available fsockopen: Available cURL: Available cURL Version: 7.68.0, OpenSSL/1.1.1f

    Reply

Last updated

Was this helpful?