How to Send Email in WordPress Step-by-Step?

Learn how to easily send emails in WordPress using three simple methods: the wp_mail() function, an SMTP plugin, or manual SMTP setup. Improve email deliverability with step-by-step instructions.

  • Published on: August 19, 2024
  • Updated on: August 19, 2024

Wasim Akram

Blog Author

WPnomy - Default Featured Image

If you’re like most WordPress users, you’ve probably faced the frustrating issue of emails not being sent from your website.

Whether it’s order confirmations, contact form submissions, or any other type of communication, reliable email delivery is crucial.

The good news is, you don’t have to be a tech expert to solve this problem.

In this guide, I’ll walk you through three effective methods to ensure your WordPress emails are sent and received as intended.

Method 1: Using the wp_mail() Function

The wp_mail() function is WordPress’s built-in way to send emails. It’s simple and doesn’t require any additional setup, making it a go-to option for many users.

However, it’s important to understand that this method relies on your web host’s mail server, which can lead to emails being marked as spam or not delivered at all.

Steps to Use wp_mail():

  1. Prepare Your Email:
    The wp_mail() function allows you to specify the recipient, subject, message, and even attachments. Here’s a basic example of how to use it:
   wp_mail( '[email protected]', 'Your Subject Here', 'Your message content here.' );
  1. Add the Code to Your Theme or Plugin:
    You can place the above code in your theme’s functions.php file or within a custom plugin. This ensures that the email function is triggered when needed, such as when a form is submitted.
  2. Test the Functionality:
    After saving your changes, test the function by triggering an email, for instance, by submitting a contact form. Be sure to check both the inbox and spam folder to see if the email was delivered correctly.

Why You Might Experience Issues:

The biggest drawback of using wp_mail() is its reliance on your server’s email configuration.

Many shared hosting providers don’t have optimized mail servers, leading to poor deliverability.

If you find that emails are landing in spam or not being sent at all, you might want to consider the next method.

Method 2: Using an SMTP Plugin

If you’re looking for a more reliable way to send emails from WordPress, using an SMTP (Simple Mail Transfer Protocol) plugin is highly recommended.

One of the most popular plugins for this purpose is WP Mail SMTP by WPForms.

Steps to Use an SMTP Plugin:

Install the Plugin:

    • Log in to your WordPress admin dashboard.
    • Navigate to Plugins > Add New.
    • Search for WP Mail SMTP by WPForms.
    • Click Install Now, then Activate.

    Configure the Plugin:

      • Go to WP Mail SMTP in your dashboard menu.
      • Under the General tab, set your From Email (e.g., [email protected]) and From Name (e.g., Your Website Name).
      • In the Mailer section, choose your SMTP service (e.g., Other SMTP for custom settings).

      Enter Your SMTP Settings:

        • Fill in the details provided by your email service provider:
          • SMTP Host: For example, smtp.gmail.com if you’re using Gmail.
          • SMTP Port: Use 465 for SSL or 587 for TLS encryption.
          • Encryption: Choose between SSL or TLS based on your provider’s recommendation.
          • SMTP Username: Your full email address.
          • SMTP Password: The password for your email account.

        Send a Test Email:

          • Go to the Email Test tab within the plugin settings.
          • Enter a valid email address and click Send Email.
          • Check the inbox of the recipient email to confirm successful delivery.

          Benefits of Using an SMTP Plugin:

          Using an SMTP plugin like WP Mail SMTP greatly improves email deliverability.

          Unlike the wp_mail() function, which relies on your hosting server, SMTP sends emails through a designated email provider, reducing the chances of emails being flagged as spam.

          Other great alternatives include Post SMTP and FluentSMTP, which also offer robust features for reliable email sending.

          Method 3: Manually Configuring SMTP

          For those who prefer a hands-on approach and don’t mind getting into the technical details, manually configuring SMTP settings is another option.

          This method involves adding your SMTP credentials directly to your WordPress files, giving you more control over your email configuration.

          Steps to Manually Configure SMTP:

          1. Edit Your wp-config.php or functions.php File:
          • Open your site’s wp-config.php or functions.php file via FTP or your hosting control panel.
          • Add the following code, replacing the placeholder values with your actual SMTP credentials:
             add_action( 'phpmailer_init', 'my_phpmailer_smtp' );
             function my_phpmailer_smtp( $phpmailer ) {
                 $phpmailer->isSMTP();
                 $phpmailer->Host = 'smtp.yourhost.com'; // Your SMTP server
                 $phpmailer->SMTPAuth = true;
                 $phpmailer->Port = 465; // Use 587 for TLS
                 $phpmailer->Username = '[email protected]';
                 $phpmailer->Password = 'your_password';
                 $phpmailer->SMTPSecure = 'ssl'; // Use 'tls' for TLS
                 $phpmailer->From = '[email protected]';
                 $phpmailer->FromName = 'Your Name';
             }
          1. Send an Email:
          • Use the wp_mail() function, as described in Method 1, to send emails through your manually configured SMTP setup.

          Advantages and Considerations

          Manually configuring SMTP gives you more flexibility and control over how emails are sent from your WordPress site.

          However, this method is more complex and requires a good understanding of PHP and WordPress file structure.

          If done incorrectly, it can cause issues with your site, so proceed with caution or consider using an SMTP plugin if you’re not confident with code.

          Conclusion

          Getting emails to send reliably from WordPress doesn’t have to be a headache.

          Whether you choose to use the wp_mail() function, an SMTP plugin, or manually configure your SMTP settings, each method offers a solution to fit different needs and technical skill levels.

          Personally, I find that using an SMTP plugin strikes the best balance between ease of use and reliable email delivery.

          Which method do you think you’ll try first? I’d love to hear your thoughts in the comments below.

          And don’t forget to explore our other blog articles related to WordPress to keep improving your website’s performance!

          0 0 votes
          Article Rating
          Subscribe
          Notify of
          guest
          0 Comments
          Most Voted
          Newest Oldest
          Inline Feedbacks
          View all comments

          Related Posts You’ll Love

          Keep exploring and sharpen your WordPress skills with more expert guides, tips, and inspiration tailored just for you. Each post is carefully crafted to help you build faster, solve real-world challenges, and get the most from WP.

          Explore More Posts
          WPnomy - Default Featured Image

          How to Auto-Adjust Hero Section Spacing for Sticky Headers in Bricks Builder?

          Learn how to automatically adjust the top spacing of your hero section to prevent content from being hidden when the sticky header is activated in Bricks Builder. This quick guide…

          Read Now
          WPnomy - Default Featured Image

          My Top Concerns About the Bricks Builder Ecosystem as a Committed Member

          A quick look at what really holds the Bricks Builder ecosystem together, and where things could use some work. Whether you’re new or experienced, understanding this helps us all move…

          Read Now
          WPnomy - Default Featured Image

          What is the Best Theme to Use with Bricks Builder?

          Many people search for the perfect theme to pair with Bricks Builder, but the real answer might not be what you expect. The best fit could be hiding in plain…

          Read Now

          Connect. Learn. Build Together.

          Become part of the WPnomy family; a vibrant, supportive community where freelancers, designers, and agencies come together to share insights, ask questions, and celebrate wins. Here, you’ll find encouragement, real-world tips, and a network of passionate WordPress users ready to help you grow.

          Join Facebook Community
          • Connect with passionate WordPress users who share your goals and challenges.
          • Access practical tips, insider tricks, and real-world solutions tailored for all skill levels.
          • Share your progress, get feedback, and celebrate your wins with a supportive network.
          • Stay updated on the latest WordPress features, tutorials, and community events.
          • Experience friendly mentorship and no-fluff guidance, making web building easier and more fun.
          Black Friday Background Image

          🖤 Wait! Don’t Miss These Black Friday Deals!

          Before you go, grab these exclusive 2025 Black Friday Deals; huge savings on top WordPress themes, powerful plugins, and reliable hosting to level up your site. These offers vanish soon, claim your deal now!

          Unlock My Black Friday Deals