Step-by-Step Guide to Configure Gmail SMTP for WordPress Without Plugins

Gmail SMTP wordpress without plugins

Yes, it is possible to configure Gmail for WordPress without using plugins. This can be achieved by setting up Gmail as your SMTP (Simple Mail Transfer Protocol) server for outgoing emails from your WordPress site. SMTP is the industry standard for sending emails and using Gmail’s SMTP server ensures reliable delivery of your emails.

Sometimes, Plugins that are supposed to help can make your site slow or even open doors for hackers. So, we at Hostious are here to help you configure SMTP without a plugin for sending and receiving emails. . Let’s jump into it!

Table Of Content

Understanding SMTP and Its Importance for WordPress Websites

SMTP, standing for Simple Mail Transfer Protocol, is a pivotal protocol used for sending and receiving emails across the internet. When an email is dispatched, SMTP facilitates its journey from one server to another, ensuring reliable and secure email communication.

By default, WordPress uses the PHP mail function for its email services. However, this function often faces configuration issues, and some hosting providers disable it to curb spam, leading to unreliable email delivery. To address this, integrating an SMTP server into WordPress is a recommended solution. By doing so, it bypasses the limitations of the PHP mail function, offering a more stable and efficient way to handle emails, significantly reducing the risk of your emails being marked as spam and improving deliverability rates. This enhancement is crucial for WordPress sites to maintain effective communication with their users.

Optimizing Email Delivery with Gmail SMTP for WordPress (2 options)

WordPress emails are often flagged as spam due to the default wp_mail() function’s lack of header authentication. This function, which relies on PHP’s mail(), is frequently blocked by hosting providers, leading to poor email deliverability. Emails end up in spam folders or are discarded entirely, limiting the effectiveness of your website’s communication.

SMTP (Simple Mail Transfer Protocol) offers a more secure alternative. Gmail’s SMTP server, especially suitable for small WooCommerce stores or WordPress sites with moderate traffic, provides the necessary security features missing in the PHP mail function.

For WordPress users, there are two Gmail SMTP options:

  1. Free Gmail SMTP: Suitable for small-scale use, but limits control over DNS records and caps daily email sends at 500.
  2. Google Workspace SMTP: Offers custom domain setup ([email protected]) and verification through SPF, DKIM, and DMARC records, enhancing sender reputation and email deliverability. However, it too has limitations, restricting daily sends to 10,000 emails.

For bulk email sending, consider third-party services, which cater to higher volumes. Before proceeding, ensure you have access to a Google Workspace or Gmail account to set up SMTP for your WordPress site. Otherwise, we will show you how at the very beginning of the next section.

Configure Gmail for WordPress without using plugins

Configuring Gmail for WordPress without using plugins involves setting up SMTP (Simple Mail Transfer Protocol) settings directly in your WordPress files. Here’s a step-by-step guide:

1. Create a Google App to get OAuth 2.0 credentials:

image 9
Step-by-Step Guide to Configure Gmail SMTP for WordPress Without Plugins 6
Add the gmail API to your new project to configure gmail
Step-by-Step Guide to Configure Gmail SMTP for WordPress Without Plugins 7
  • Create credentials (OAuth client ID) for your WordPress site. You will get a client ID and client secret, which are needed for authentication.
Create credentials
Step-by-Step Guide to Configure Gmail SMTP for WordPress Without Plugins 8

2. Access Your WordPress Files:

  • You need to edit two key files: wp-config.php and functions.php​.
  • wp-config.php is in the root of your WordPress installation. Access it via FTP or SSH.
Accessing wp-config through hosting panel
Step-by-Step Guide to Configure Gmail SMTP for WordPress Without Plugins 9
  • functions.php can be found in your WordPress admin dashboard under Appearance > Theme Editor.

(It is highly recommended whatever changes you are making, you should first create the Child theme and make the necessary changes in the child theme only).

This method requires you to manually input your Gmail credentials and modify key WordPress files. Be cautious, as errors in these files can affect your site’s functionality. If you’re not comfortable editing code, consider alternative methods or seek assistance from a developer.

3. Edit wp-config.php File:

  • Add the following lines to your wp-config.php file:
define('SMTP_USER', '[email protected]'); // Your Gmail address
define('SMTP_PASS', 'your-gmail-password'); // Your Gmail password
define('SMTP_HOST', '');
define('SMTP_FROM', '[email protected]'); // 'From' email address
define('SMTP_NAME', 'Your Name'); // 'From' name
define('SMTP_PORT', 587); // Gmail SMTP port (TLS)
define('SMTP_SECURE', 'tls'); // Encryption type
define('SMTP_AUTH', true); // Enable SMTP authentication
  • Replace the placeholders with your actual Gmail details

You can write the code anywhere in the wp-config.php file but before this line /* That’s all, stop editing! Happy blogging. */.

4. Edit functions.php File:

  • Ideally, edit the functions.php file of your child theme to avoid losing changes during theme updates.
  • Add the following code to functions.php:
add_action('phpmailer_init', 'custom_phpmailer_init');
function custom_phpmailer_init($phpmailer) {
    $phpmailer->Host = SMTP_HOST;
    $phpmailer->SMTPAuth = SMTP_AUTH;
    $phpmailer->Port = SMTP_PORT;
    $phpmailer->Username = SMTP_USER;
    $phpmailer->Password = SMTP_PASS;
    $phpmailer->SMTPSecure = SMTP_SECURE;
    $phpmailer->From = SMTP_FROM;
    $phpmailer->FromName = SMTP_NAME;
  • This function overrides the default PHPMailer settings with your Gmail SMTP settings

5. Test the Configuration:

  • After making these changes, test your website’s email functionality, such as sending a test email from a contact form.
  • If it works, your WordPress site is now configured to send emails using Gmail’s SMTP server without a plugin.

Configuring Gmail for WordPress using SMTP is a reliable and efficient way to enhance your website’s email functionality. Whether you’re running a small WooCommerce store or a growing WordPress site, implementing Gmail’s SMTP server can significantly improve email deliverability and security. With options ranging from free Gmail SMTP to the more advanced Google Workspace SMTP, users can choose the solution that best fits their needs. It’s essential, however, to understand the setup process and limitations of each option to ensure a smooth and effective email communication strategy for your WordPress site.

Frequently Asked Questions About Gmail SMTP for WordPress

1. Why should I use Gmail SMTP over the default WordPress email function?

Gmail SMTP provides a more secure and reliable method of sending emails. Unlike WordPress’s default wp_mail() function, which often leads to emails being marked as spam, Gmail SMTP ensures better deliverability and security. It’s especially beneficial for WordPress sites facing email delivery issues.

2. Can I use Gmail SMTP for a high-volume WordPress site?

While Gmail SMTP is great for small to moderate traffic sites, it has sending limits (500 emails per day for free Gmail SMTP and 10,000 for Google Workspace SMTP). For higher volumes, it’s advisable to use third-party email services like Mailtrap Email API.

3. Is it necessary to have coding knowledge to set up Gmail SMTP without a plugin?

Yes, basic coding knowledge is required. You’ll need to edit WordPress files such as wp-config.php and functions.php, which involves a certain level of technical skill. If you’re not comfortable with coding, consider using a plugin or seek professional assistance.

4. What are the advantages of using Google Workspace SMTP over free Gmail SMTP?

Google Workspace SMTP allows for a custom domain ([email protected]) and provides additional security features like SPF, DKIM, and DMARC records. This enhances your sender reputation and improves email deliverability. However, it’s a paid service with its own sending limits.

5. How do I test my WordPress site’s email functionality after setting up Gmail SMTP?

After configuration, conduct a test by sending emails from your WordPress site, such as through a contact form. This helps ensure that the SMTP settings are correctly implemented and that emails are being sent successfully through Gmail’s SMTP server.

Similar Posts

Leave a Reply